我目前正在使用PayPals API,并希望将其响应之一从名称 - 值对转换为数组.
到目前为止,我已经习惯urldecode()解码对以下内容的响应:
RECEIVERBUSINESS=foo@bar.com&RECEIVEREMAIL=another@email.com&MOREINFO=lots more info`
Run Code Online (Sandbox Code Playgroud)
我想要的是拥有以下内容:
RECEIVERBUSINESS => 'foo@bar.com'
RECEIVEREMAIL => 'another@email.com'
MOREINFO => 'lots more info'
Run Code Online (Sandbox Code Playgroud)
我只是不太确定如何到达那里!
Tim*_*per 18
parse_str 正是你要找的:
parse_str('RECEIVERBUSINESS=foo@bar.com&RECEIVEREMAIL=another@email.com&MOREINFO=lots more info', $arr);
/*
print_r($arr);
Array
(
[RECEIVERBUSINESS] => foo@bar.com
[RECEIVEREMAIL] => another@email.com
[MOREINFO] => lots more info
)
*/
Run Code Online (Sandbox Code Playgroud)