我使用paypal api來獲取收款人信息。
我得到了json結果。如何獲得email
,first_name
,last_name
不同的變量PHP Json格式變量聲明
這裏是JSON結果:
{
id: "PAY-4L2624428H450980CLD23F4A",
intent: "sale",
state: "approved",
cart: "74345738MA858411Y",
payer: {
payment_method: "paypal",
status: "VERIFIED",
payer_info: {
email: "[email protected]",
first_name: "test",
last_name: "facilitator",
payer_id: "Z2ZSX2WM9ALD2",
shipping_address: {
recipient_name: "test facilitator"
},
country_code: "SG"
}
}
}
使用谷歌,你會發現PHP函數[json_decode()](http://php.net/manual/en/function.json-decode.php)如果第二個參數設置爲「true」,則轉換將返回JSON作爲關聯數組。 –
鑑於json不是有效的json請檢查[http://jsonviewer.stack.hu/] –