JSON數據
"orders":[
"billing_details":{
"company":"Test Company",
"firstname":"Munadil",
"postcode":"5000",
"street":"Dhaka, Bangladesh",
"email":"[email protected]",
"lastname":"Fahad",
"ph_number":"880191111111",
"city":"Dhaka",
"state":"Mirpur",
"country_code":"BN",
"user_id":16003511,
"salutation":null
}]
在PHP
$json_output = json_decode($response);
foreach ($json_output->orders as $orders){
foreach ($orders->billing_details as $billing_details) {echo "<b>Name:</b><br>".$billing_details->firstname." ".$billing_details->lastname."<br>";}
}
但我得到以下錯誤消息,如何在php中回顯json對象屬性?
注意:試圖讓....
非對象的屬性如何在陣列「訂單」下回顯「billing_details」對象中的數據?
'billing_details'是陣列內的鍵。試試'「命令」:[{...}]' –
你在哪裏聲明瞭變量$ orders? – victor
這是無效的JSON。 – trincot