$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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]