Re: URL Parsing Help

From: Date: Tue, 29 Jan 2002 22:58:48 +0000
Subject: Re: URL Parsing Help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-82621@lists.php.net to get a copy of this message
$myPairs = explode( "/", $PATH_INFO ); while( list( $key, $val ) = each( $myPairs ) ){ if( !empty( $val ) ){ $myVar = explode( "=", $val ); ${$myVar[0]} = $myVar[1]; } } For you example URI, "index.php/option=contact/step=view" you would then have $option and $step available, with the assigned values of "contact" and "view", respectively. ~Chris /"\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden On Tue, 29 Jan 2002, Shane Lambert wrote: > I am trying to write software that will allow me to pass variables to a php > script like: > > index.php/option=contact/step=view > > When I do this, I get the varibal PATH_INFO which contains > "/option=contact/step=view". Now, what I want is to have the following: > > $option = "contact" > $step = "view" > > I tried using '$array = explode("/",$PATH_INFO);' which gives me the array: > > $array[1] = "option=contact" > $array[2] = "step=view" > > This of course is not what I want. I want: > > $array[option] = "contact" > $array[step] = "view" > > So that when I use the extract($array) command I get the variables: > > $option = "contact" > $step = "view" > > Like I want. If you aren't lost and you know the answer, PLEASE HELP! > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#82621) next »