note 45123 deleted from features.commandline by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 26 Aug 2004 20:07:54 +0000 |
| Subject: | note 45123 deleted from features.commandline by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75354@lists.php.net to get a copy of this message | ||
Note Submitter: php at deathz0rz dot homeunix dot net
----
To parse the command line arguments, use the following script:
<?php
$args=array();
for($i=1;$i<$argc;++$i)
$args[$argv[$i]]=$argv[++$i];
?>
./arguments.php -v 1 -username deathz0rz
will produce:
Array
(
[-v] => 1
[-username] => deathz0rz
)
note that this script is intended for use with options that take an argument (like -port 8080). -v
-port 8080 -q -r wont work.