Voting

: one plus four?
(Example: nine)

The Note You're Voting On

eric dot brison at anakeen dot com
17 years ago
Just a variant of previous script to accept arguments with '=' also
<?php
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';
}

}
return
$_ARG;
}
?>
$ php myscript.php --user=nobody --password=secret -p --access="host=127.0.0.1 port=456"
Array
(
[user] => nobody
[password] => secret
[p] => true
[access] => host=127.0.0.1 port=456
)

<< Back to user notes page

To Top