|
getoptGets options from the command line argument list Description
array getopt
( string
$options
[, array $longopts
] )Parses options passed to the script. Parameters
The
Return Values
This function will return an array of option / argument pairs or
Changelog
Examples
Example #1 getopt example
<?phpRunning the above script with php script.php -fvalue -h will output:
array(2) {
["f"]=>
string(5) "value"
["h"]=>
bool(false)
}
Example #2 getopt example#2
<?phpRunning the above script with php script.php -f "value for f" -v -a --required value --optional="optional value" --option will output:
array(6) {
["f"]=>
string(11) "value for f"
["v"]=>
bool(false)
["a"]=>
bool(false)
["required"]=>
string(5) "value"
["optional"]=>
string(14) "optional value"
["option"]=>
bool(false)
}
Example #3 getopt example#3 Passing multiple options as one
<?phpRunning the above script with php script.php -aaac will output:
array(2) {
["a"]=>
array(3) {
[0]=>
bool(false)
[1]=>
bool(false)
[2]=>
bool(false)
}
["c"]=>
bool(false)
}
|