0 && $_l < 3) { // one or two dashes, then we set that the variable is present $pName = substr($_SERVER['argv'][$i], strspn($_SERVER['argv'][$i],'-')); self::$params[$pName] = TRUE; } else { if ($pName) { // the parameter $pName is present and there is a value for it, so we change from TRUE // to the value. If there is a value set for $pName and not TRUE than we make an // an array by adding the already set value and also adding the $_SERVER['argv'][$i] if (!is_array(self::$params[$pName])) { if (self::$params[$pName] !== TRUE) { self::$params[$pName] = array(self::$params[$pName]); self::$params[$pName][] = $_SERVER['argv'][$i]; } else { self::$params[$pName] = $_SERVER['argv'][$i]; } } else { self::$params[$pName][] = $_SERVER['argv'][$i]; } }// if }// if ++$i; }// while }// if if (array_key_exists($name, self::$params)) { return self::$params[$name]; } else if (array_key_exists($name, self::$defaultParamValues)) { return self::$defaultParamValues[$name]; } else { return NULL; } }// getOptionValue public static function setDefaultParamValues($a) { self::$defaultParamValues = $a; return TRUE; } } //CmdOpts::setDefaultParamValues(array('fubar'=>432)); //var_dump(CmdOpts::getOptionValue('bla')); //var_dump(CmdOpts::getOptionValue('fubar')); ?>