Reputation: 4491
I am currently working with PayPals API and want to transform one of its response from a name-value pair to an array.
So far I have used urldecode()
to decode the response to the following:
[email protected]&[email protected]&MOREINFO=lots more info`
What I would like is to have the following:
RECEIVERBUSINESS => '[email protected]'
RECEIVEREMAIL => '[email protected]'
MOREINFO => 'lots more info'
I'm just not quite sure how to get there!
Upvotes: 11
Views: 10371
Reputation: 732
Look into explode
-
// poulate array from URL parameters
$returnedInfo = explode('&', $dataStringFromUrl);
Upvotes: -3
Reputation:
parse_str
is what you're looking for:
parse_str('[email protected]&[email protected]&MOREINFO=lots more info', $arr);
/*
print_r($arr);
Array
(
[RECEIVERBUSINESS] => [email protected]
[RECEIVEREMAIL] => [email protected]
[MOREINFO] => lots more info
)
*/
Upvotes: 22