As an example, if I pass an argument to a script such as ....
"some_script -p Jack -u Dempsy"
... then the data structure I get back is something like...
Array
(
[0] => Array
(
[0] => Array
(
[0] => p
[1] => Jack
)
[1] => Array
(
[0] => u
[1] => Dempsy
)
)
[1] => Array
(
)
)
Now is it just me or is that kind of cumbersome? Wouldn't it be nice to get back something like...
Array
(
[p] => Jack
[u] => Dempsy
)
That said, I wrote this.
function &condense_arguments($args)
{
$new_args_list=array();
foreach($args[0] as $arg)
{ $new_args_list[$arg[0]]=$arg[1]; }
return $new_args_list;
}
This will provide the type of data structure we're talking about.
I sent this as a note to "somebody" at the PEAR site. It would be great if I could actualy send it straight to a maintainer but the site doesn't seem to support this.
Now let's see what happens shall we?
No comments:
Post a Comment