metawidget: A platypus looking pensive. (Default)
How ugly is this approach to making a copy of an array that moves only values, not references?

$copy_of_array = unserialize(serialize($multidimensional_array));

I feel a little dirty... assuming I'm not too worried about efficiency, should I?
metawidget: A platypus looking pensive. (Default)

update: fixed with help from [livejournal.com profile] plautus (and an interesting alternate explanation from [livejournal.com profile] tylerpistol)


I'm writing some PHP to take XML from a file. The file's in ISO-8859-1, and contains French accents and typesetter's quotes in its character data and some of its attributes. I've taken care to make the parser adapt itself to the character set and demanded that its target character set is also ISO-8859-1:

$xml_parser = xml_parser_create("");
xml_parser_set_option($xml_parser,XML_OPTION_TARGET_ENCODING,"ISO-8859-1");
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING, 0);

...

I set up a tag handler to turn an "in_prose" variable on and off (based, not surprisingly, on whether the parser is inside a "prose" element), when it's on I want to suck it into an array element using my cdataHandler function:

...

function cdataHandler($parser,$data){
	if ($_SESSION["in_prose"]){
		$_SESSION["evenements"][$_SESSION["current_event"]]["prose"]=$data;
	}
}

Alas, it tends to chop off the beginning of the text. It's not predictably before any given character, or any predictable length, as far as I can tell. It's just dismembered when I echo it back. Any idea what might be causing this? Any safety measures I can take?

metawidget: A platypus looking pensive. (Default)
Help!

I'm trying to get a Perl script wrapped in Platypus to set its working directory to the current one... it has an example using "$1/.." for sh, but I'm a total novice and don't know how to get perl to either do that right away or fold it into a system() call. I just want the script to run a command from the directory it's sitting in (I can't predict what directory the user will drop it in, but the files the command acts on will be in the right relative spots).

If anyone has an idea how to access what Platypus gives to sh as "$1" from Perl, or another way to do this, I'd be much obliged.

Profile

metawidget: A platypus looking pensive. (Default)
metawidget
Page generated Jun. 18th, 2025 07:18 pm

June 2025

S M T W T F S
123 4567
89 1011121314
15 161718192021
22232425262728
2930     

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Powered by Dreamwidth Studios