{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderre":"输入的产品ID不存在","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderre":"输入必选参数为空","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderre":"输入必选参数为空","baseLine":""}]} 怎么得到其中"orderresult":"6"的值,也就是6
解决方案 »
- 在ecshop中can't write不能写入的原因以及解决方法
- PHP的中文在线手册及如何参与PHP文档的中文翻译
- phpexcel导出excel两级联动列表的不可用
- safari浏览器报Your copy of safari is missing important software resources如何解决?
- 提问: 这个网站的流媒体是如何实现的,采用的是什么方法
- 怎么安装gd库
- PHP 编译的程序问题 急啊高手不要潜水了出来了
- linux系统下安装php,make install是出错
- 《PHP+Ajax Web 2.0编程技术与项目开发》后台登陆账号密码
- 安装XAMPP过程中出现的一个问题
- zend studio 能调试html文件吗,如网站先是从index.html再获取index.php上的变量的
- CMS页面传值的的问题!!困了我好久了。
$json = <<<JSON
{"head":[{"visitcode":"sjbtg","resultCode":"0"}],"content":[{"userID":"15611030868","productID":"3111007900 ","orderTime":"2012-06-19","orderType":"1","orderresult":"6","orderre":"输入的产品ID不存在","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderre":"输入必选参数为空","baseLine":"","orderField":""},{"userID":"","productID":"","orderTime":"","orderType":"1","orderresult":"1","orderre":"输入必选参数为空","baseLine":""}]}
JSON;
$obj = json_decode($json);
print_r($obj);
#stdClass Object ( [head] => Array ( [0] => stdClass Object ( [visitcode] => sjbtg [resultCode] => 0 ) ) [content] => Array ( [0] => stdClass Object ( [userID] => 15611030868 [productID] => 3111007900 [orderTime] => 2012-06-19 [orderType] => 1 [orderresult] => 6 [orderre] => 输入的产品ID不存在 [baseLine] => [orderField] => ) [1] => stdClass Object ( [userID] => [productID] => [orderTime] => [orderType] => 1 [orderresult] => 1 [orderre] => 输入必选参数为空 [baseLine] => [orderField] => ) [2] => stdClass Object ( [userID] => [productID] => [orderTime] => [orderType] => 1 [orderresult] => 1 [orderre] => 输入必选参数为空 [baseLine] => ) ) )#stdClass Object表示对象,用->来访问其下元素;
echo $obj->head[0]->visitcode; #sjbtg
#Array表示数组,用[]来访问其下元素.