I think the function parse_str does exactly what you want.

http://www.php.net/manual/en/function.parse-str.php






----- Original Message -----
From: "Knut H. Hassel Nielsen" <[EMAIL PROTECTED]>
To: "Mike Gifford" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, April 04, 2001 6:12 PM
Subject: Re: [PHP] Building an array from a URL



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&superRS
S175=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


--
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]

Reply via email to