[英]Trying to get property 'id' of non-object {"exception":"[object]
我有一个 $data= [{"id":54,"systemid":"1610000060000000063"}]
并且我试图获得这样的 id $id = $data['id']
甚至我试过$data->id
和我正在尝试获取非对象的属性 'id' {"exception":"[object] (ErrorException(code: 0): Trying to get property 'id' of non-object)
you have an array in json format:你有一个 json 格式的数组:
$array='[{"id":54,"systemid":"1610000060000000063"}]';
first you have to decode the array:首先你必须解码数组:
$decodedArray=json_decode($array);
then get the element at index 0:然后获取索引 0 处的元素:
$object=$decodedArray[0];
then you can get it's id:然后你可以得到它的id:
$id=$object->id;
see the sandbox for it:查看它的沙箱:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.