note 76606 added to features.commandline
| From: | lucasdotvasconcelosatgmaildotcom at osu1 dot php dot net | Date: | Sun, 22 Jul 2007 18:04:35 +0000 |
| Subject: | note 76606 added to features.commandline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128824@lists.php.net to get a copy of this message | ||
Just another variant of previous script that group arguments doesn't starts with '-'
or '--'
function arguments($argv) {
$_ARG = array();
foreach ($argv as $arg) {
if (ereg('--([^=]+)=(.*)',$arg,$reg)) {
$_ARG[$reg[1]] = $reg[2];
} elseif(ereg('^-([a-zA-Z0-9])',$arg,$reg)) {
$_ARG[$reg[1]] = 'true';
} else {
$_ARG['input'][]=$arg;
}
}
return $_ARG;
}
$ php myscript.php --user=nobody /etc/apache2/*
Array
(
[input] => Array
(
[0] => myscript.php
[1] => /etc/apache2/apache2.conf
[2] => /etc/apache2/conf.d
[3] => /etc/apache2/envvars
[4] => /etc/apache2/httpd.conf
[5] => /etc/apache2/mods-available
[6] => /etc/apache2/mods-enabled
[7] => /etc/apache2/ports.conf
[8] => /etc/apache2/sites-available
[9] => /etc/apache2/sites-enabled
)
[user] => nobody
)
----
Server IP: 69.147.83.197
Probable Submitter: 201.30.110.94
----
Manual Page -- http://www.php.net/manual/en/features.commandline.php
Edit -- https://master.php.net/note/edit/76606
Del: integrated -- https://master.php.net/note/delete/76606/integrated
Del: useless -- https://master.php.net/note/delete/76606/useless
Del: bad code -- https://master.php.net/note/delete/76606/bad+code
Del: spam -- https://master.php.net/note/delete/76606/spam
Del: non-english -- https://master.php.net/note/delete/76606/non-english
Del: in docs -- https://master.php.net/note/delete/76606/in+docs
Del: other reasons-- https://master.php.net/note/delete/76606
Reject -- https://master.php.net/note/reject/76606
Search -- https://master.php.net/manage/user-notes.php