Re: Building an array from a URL

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: Building an array from a URL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47088@lists.php.net to get a copy of this message
Did you try to see if $HTTP_GET_VARS can help you ? Its an array of every variable posted by GET (the way you described) Else : Split the different key/values with the delimiter '&' and thereafter split the elements in the array by '=' But first split the string into page and variables : list( $page, $str ) = split("?","superRSS.phtml?150=1150&superRSS166=1166&superRSS168=1168&superRSS175=1188"); function make_arr_from_str( $str ) { $exp_arr = Explode( "&", $str ); $new_arr = Array(); for ( $i = 0 ; $i < count( $exp_arr ) ; $i++ ) { list( $key, $val ) = split( "=", $exp_arr[ $i ] ); $new_arr["$key"] = $val; } return $new_arr; } $array = make_arr_from_str( $str ); var_dump($array); On Wed, 4 Apr 2001, Mike Gifford wrote: > Hello, > > I'm trying to build an array out of data submitted from a URL. > > Essentially, I want to pull certain records out of a database which have been > selected on another form. > > The URL presently looks like this: > superRSS.phtml?150=1150&superRSS166=1166&superRSS168=1168&superRSS175=1188 > > I'd like to take these independent variables and merge them into a single array: > $array_superRSS = implode (":", $superRSS[]); > > So I can then pipe these values directly into another function: > > while ($array_superRSS) { > display_superRSS($array_superRSS[]); > } > > Obviously I'm missing a step or two here, but would really appreciate someone > filling in some of the gaps. > > Thanks! > > Mike > -- Knut ------ Knut H. Hassel Nielsen Principal Engineer / Avdelingsingeniør Norwegian University of Science and Technology / NTNU Department of Computer and Information Science / IDI N-7491 Trondheim, Norway Phone Office / Telefon jobb : (+47) 73 59 18 46 Fax Office / Telefax jobb : (+47) 73 59 17 33 Cell. Phone / Mobiltelefon : 91 59 86 06

« previous php.general (#47088) next »