如何在php 中解析带有数组的JSON 字符串I am sending a JSON string in php post request. JSON string look like this:At server side i want to get mobile, otp and pid and vid for all items.
I am getting mobile number from this:
But when i am trying to get pid and vid like this:
i am getting error: Trying to get property of non-object.
How to solve this?
Edit:If there is any better way to parse JSON in php, please suggest that also.{"mobile":"0000000000","otp":"970996", "items":[{"pid":"12", "vid":"20"},{"pid":"13", "vid":"2"}]}1
phpjson格式化输出$data = json_decode(file_get_contents('php://input'), true );2
//print_r($data);3echo  $data["mobile"];1
foreach ($data["items"] as  $mydata){2 3
echo  $mydata->pid;4}
图⽚转代码服务由CSDN 问答提供 功能建议展开全部

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。