>  기사  >  백엔드 개발  >  获取某一元素有关问题,

获取某一元素有关问题,

WBOY
WBOY원래의
2016-06-13 13:27:03957검색

获取某一元素问题,急
{"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

------解决方案--------------------

探讨

$s = '{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderremark":"输入的产品ID不存……
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.