我目前正在使用PayPals API,并希望将其响应之一从名称 – 值对转换为数组.
到目前为止,我已经使用urldecode()来解码对以下内容的响应:
RECEIVERBUSINESS=foo@bar.com&RECEIVEREMAIL=another@email.com&MOREINFO=lots more info`
我想要的是拥有以下内容:
RECEIVERBUSINESS => 'foo@bar.com' RECEIVEREMAIL => 'another@email.com' MOREINFO => 'lots more info'
我只是不太确定如何到达那里!
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 ) */