获取某一元素有关问题,
程序员文章站
2022-04-12 18:28:28
...
获取某一元素问题,急
{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderremark":"输入的产品ID不存在","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":""}]}
怎么得到其中"orderresult":"6"的值,也就是6
------解决方案--------------------
$s = '{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderremark":"输入的产品ID不存在","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":""}]} ';
echo json_decode($s)->content[0]->orderresult; //6
------解决方案--------------------
{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderremark":"输入的产品ID不存在","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":""}]}
怎么得到其中"orderresult":"6"的值,也就是6
------解决方案--------------------
$s = '{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderremark":"输入的产品ID不存在","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderremark":"输入必选参数为空","baseLine":""}]} ';
echo json_decode($s)->content[0]->orderresult; //6
------解决方案--------------------
相关文章
相关视频