I need to parse the $_SERVER[‘argv’] array into a single array.
I can decide how to get the parameters.
So for example the script was called like this: php script.php name:jack operation:full
I get the parameters in $_SERVER[‘argv’] like this:
Array
(
[0] => script.php
[1] => name:jack
[2] => operation:full_res
)
How can I easily move those parameters into one array that would be like this:
$param :
Array(['name'] => jack ['operation'] => full_res)
You might be looking for
getopt, although it would alter the format of your arguments somewhat.From the command line: