note 41343 deleted from function.getopt by nlopess
| From: | nlopess@php.net | Date: | Fri, 09 Apr 2004 14:26:19 +0000 |
| Subject: | note 41343 deleted from function.getopt by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67890@lists.php.net to get a copy of this message | ||
Note Submitter: DERENCIUS AT H0TMA1L
----
Fixing the first post, and this function works at windows. Remember to set register_argc_argv to on
------
function getOptions($opt) {
$paramNum = $_SERVER["argc"]; # here is the fix
$paramStr = $_SERVER["argv"]; # again
for($i=1; $i<$paramNum; $i++) {
if (($paramStr[$i][0] == "-") && ($subOpt = strstr($opt,
$paramStr[$i][1]))) {
if (($subOpt[1] == ":") && ($paramStr[$i+1][0] != "-")) {
$param[$paramStr[$i][1]] = $paramStr[$i+1];
$i++;
} else {
$param[$paramStr[$i][1]] = "";
}
}
}
return $param;
}
$options = getOptions("i:f:");