[英]getting value of element in json response
我得到的我的json响应
$str = '{"Refund_Order_Result":{"reason":"","refund_status":0}} ';
$refoutput = json_decode($str,true);
print $refoutput->Refund_Order_Result->refund_status;
我想获取无法做到的return_status的值。 任何获得价值的方法
echo "<pre>";print_r($refoutput);//see this is an array so use below code
echo $refoutput['Refund_Order_Result']['refund_status'];
要么
$refoutput = json_decode($str);//remove true this wil return object
echo $refoutput->Refund_Order_Result->refund_status;
注意 :如果为TRUE
,则返回的objects
将转换为associative arrays.
您使用过true,所以您得到的不是array
object
$refoutput = json_decode($str,true);
上面的变量将提供一个数组,因此您必须使用下面给出的代码...
$refoutput['Refund_Order_Result']['refund_status']
$refoutput['Refund_Order_Result']['refund_status'];
尝试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.