note 36231 rejected from features.commandline by betz
| From: | betz@php.net | Date: | Wed, 01 Oct 2003 22:29:20 +0000 |
| Subject: | note 36231 rejected from features.commandline by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57562@lists.php.net to get a copy of this message | ||
Note Submitter: Spider.007
----
My version of PHP didn't support the $argv and $argc variables anymore; so I wrote this:
<?PHP
function cmd_args(){
// Returns an array containing the command line arguments
$args = (array_keys($_GET));
str_replace(getcwd(), '', $args);
$args = $args[0];
$args = explode('_', $args);
unset($args[0], $args[1], $args[2]);
ksort($args);
return $args;
}
?>
It generates an array with the arguments given on the command line and will return an array like
this:
<?
Array
(
[3] => this
[4] => is
[5] => a
[6] => test
)
?>