"orders":[
"billing_details":{
"company":"Test Company",
"firstname":"Munadil",
"postcode":"5000",
"street":"Dhaka, Bangladesh",
"email":"munadil98@gmail.com",
"lastname":"Fahad",
"ph_number":"880191111111",
"city":"Dhaka",
"state":"Mirpur",
"country_code":"BN",
"user_id":16003511,
"salutation":null
}]
$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>";}
}
但我收到以下错误消息,
注意:尝试在....中获取非对象的属性
如何在里面回复数据&#34; billing_details&#34;数组下的对象&#34;命令&#34; ?
答案 0 :(得分:1)
试试这个
$json_output = json_decode($response['orders']);
echo $json_output;
答案 1 :(得分:1)
试试这个:
template<typename T, typename U>
T safer_cast(const U& from) {
T to;
memcpy(&to, &from, (sizeof(T) > sizeof(U) ? sizeof(U) : sizeof(T)));
return to;
}