Changeset 74 for trunk/www/Base/Global.php
- Timestamp:
- Aug 23, 2009, 9:38:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/Base/Global.php
r69 r74 73 73 } 74 74 75 function ParseCommandLineArgs($argv) 76 { 77 array_shift($argv); 78 $out = array(); 79 foreach ($argv as $arg) 80 { 81 if(substr($arg,0,2) == '--') 82 { 83 $eqPos = strpos($arg,'='); 84 if($eqPos === false) 85 { 86 $key = substr($arg,2); 87 $out[$key] = isset($out[$key]) ? $out[$key] : true; 88 } else 89 { 90 $key = substr($arg,2,$eqPos-2); 91 $out[$key] = substr($arg,$eqPos+1); 92 } 93 } else if(substr($arg,0,1) == '-') 94 { 95 if(substr($arg,2,1) == '=') 96 { 97 $key = substr($arg,1,1); 98 $out[$key] = substr($arg,3); 99 } else 100 { 101 $chars = str_split(substr($arg,1)); 102 foreach($chars as $char) 103 { 104 $key = $char; 105 $out[$key] = isset($out[$key]) ? $out[$key] : true; 106 } 107 } 108 } else 109 { 110 $out[] = $arg; 111 } 112 } 113 return($out); 114 } 115 75 116 ?>
Note:
See TracChangeset
for help on using the changeset viewer.