11

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!

2 Answers 2

21

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
)
*/
Sign up to request clarification or add additional context in comments.

Comments

-3

Look into explode -

// poulate array from URL parameters
$returnedInfo = explode('&', $dataStringFromUrl);

http://us.php.net/explode

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.