Paulkirkewalker Posted May 18, 2007 Share Posted May 18, 2007 Hi there, I've used the cUrl library to return a query string from a remote server to a variable. The query string looks a bit like this: ...php?message_id=a1&recipient=unit1&sendday=fri At the moment, the whole of this query string is contained in a single variable ($qstring) so if I print $qstring, "message_id=a1&recipient=unit1&sendday=fri" will be sent to the browser. Can anyone tell me how to break the values "a1", "unit1" and "fri" into individual variables so that I can start using them in the rest of my code like this: $message_id = "a1"; $recipient = "unit1"; $sendday = "fri"; I'd like to achive this in the same php script rather than sending it to another page to GET the elements of the query string. Thanks in advance, Paul. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted May 19, 2007 Share Posted May 19, 2007 $str = 'message_id=a1&recipient=unit1&sendday=fri'; $parts = explode('&', $str); foreach ($parts as $var) { $var = explode('=', $var); $$var[0] = $var[1]; } echo $message_id . "<br />" . $recipient . '<br />' . $sendday; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.