Author Topic: Parse string into variables  (Read 256 times)

0 Members and 1 Guest are viewing this topic.

Offline clay1Topic starter

  • Enthusiast
  • Posts: 161
    • View Profile
Parse string into variables
« on: March 12, 2010, 05:12:21 PM »
I need to take a string and separate it into a set of variables or an associative array

&Accepted=1&Accepted_msg=Warning%20dialer%5Fsource%5Fid%20is%200&error=0&Error_desc=

The fields are delimited by &

I'd like to get that to be something like:

$accepted = 1
$accepted_message = "warning dialer source..'
$error_desc =





Offline wildteen88

  • Guru
  • 'Insane!'
  • *
  • Posts: 12,021
  • Gender: Male
    • View Profile
Re: Parse string into variables
« Reply #1 on: March 12, 2010, 05:29:18 PM »
You could use parse_str(), example

$str 'Accepted=1&Accepted_msg=Warning%20dialer%5Fsource%5Fid%20is%200&error=0&Error_desc=';
parse_str($str$output);

echo 
'<pre>'.print_r($outouttrue).'</pre>';