note 74190 added to function.getopt
| From: | koenbollen at gnospamail dot com | Date: | Thu, 29 Mar 2007 08:51:44 +0000 |
| Subject: | note 74190 added to function.getopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124910@lists.php.net to get a copy of this message | ||
After you use the getopt function you can use the following script to update the $argv array:
<?php
$options = "c:ho:s:t:uvV";
$opts = getopt( $options );
foreach( $opts as $o => $a )
{
while( $k = array_search( "-" . $o, $argv ) )
{
if( $k )
unset( $argv[$k] );
if( preg_match( "/^.*".$o.":.*$/i", $options ) )
unset( $argv[$k+1] );
}
}
$argv = array_merge( $argv );
?>
Note: I used the array_merge function to reindex the array's keys.
Cheers, Koen Bollen
----
Server IP: 194.109.193.76
Probable Submitter: 213.84.34.16
----
Manual Page -- http://www.php.net/manual/en/function.getopt.php
Edit -- https://master.php.net/note/edit/74190
Del: integrated -- https://master.php.net/note/delete/74190/integrated
Del: useless -- https://master.php.net/note/delete/74190/useless
Del: bad code -- https://master.php.net/note/delete/74190/bad+code
Del: spam -- https://master.php.net/note/delete/74190/spam
Del: non-english -- https://master.php.net/note/delete/74190/non-english
Del: in docs -- https://master.php.net/note/delete/74190/in+docs
Del: other reasons-- https://master.php.net/note/delete/74190
Reject -- https://master.php.net/note/reject/74190
Search -- https://master.php.net/manage/user-notes.php