Skip to content
Advertisement

How can I parse command line arguments in PHP?

I call a PHP script from command line $ php my_script.php --num1=124 --first_name=don

How can I get access to any key value pairs passed into this script? The keys can be arbitrary, so using getopt() with particular values will not work.

Here is what I want access to in my script:

JavaScript

If I use var_dump($argv), I get this output:

JavaScript

Should I just look

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement