高手帮忙输出一下这个数组吧.头痛死了. 本帖最后由 sdyizhe 于 2012-03-01 21:47:46 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php$json='{ "CC": 0, "Atime": "2012-03-01 08:00:00", "class": { "cId": 1, "cname": "ceshi", "cer": "jia", "csum": 014, "cpic": "http://127.0.0.1/s-001.png" }, "comment": "0121", "commentCount": 1, "fId": 01432, "Create": "2012-03-01 15:31:10", "id": 001, "BCount": 0, "Bitem": { "BId": 001, "Bd": 01001, "Bpic": "http://127.0.0.1/B001.jpg", "Bp": 12, "BUID": 124, "BT": "我是测试" }, "BUrl": "http://127.0.0.1", "BOT": { "OID": 02002, "OCI": 12451, "BCTime": "2012-03-01 15:31:17" }, "PRI": "PUBLIC", "SER": { "FPIC": "http://127.0.0.1/001.png", "SId": 454291526, "SName": "", "SCK": "admin", "Sum": 8 }, "SCE": "RATE", "STA": "TOP", "UPtime": "2012-02-28 10:03:55", "click": 3}';$json=preg_replace('/\:\s+([^"\}]*?),\}?/',': "$1",',$json);print_r(json_decode($json,true));?> 上面的有点小错误,修正如下:<?php$json='{"CC":0,"Atime":"2012-03-01 08:00:00","class":{"cId":1,"cname":"ceshi","cer":"jia","csum":014,"cpic":"http://127.0.0.1/s-001.png"},"comment":"0121","commentCount":1,"fId":01432,"Create":"2012-03-01 15:31:10","id":001,"BCount":0,"Bitem":{"BId":001,"Bd":01001,"Bpic":"http://127.0.0.1/B001.jpg","Bp":12,"BUID":124,"BT":"我是测试"},"BUrl":"http://127.0.0.1","BOT":{"OID":02002,"OCI":12451,"BCTime":"2012-03-01 15:31:17"},"PRI":"PUBLIC","SER":{"FPIC":"http://127.0.0.1/001.png","SId":454291526,"SName":"","SCK":"admin","Sum":8},"SCE":"RATE","STA":"TOP","UPtime":"2012-02-28 10:03:55","click":3}';$json=preg_replace('/\s/','',$json);$json=preg_replace('/\:\s*([^"\}]*?),\}?/',': "$1",',$json);print_r(json_decode($json,true));?> 非常感谢!我没说清楚,实在不好意思,我要单独调用一些的,因为我还要排版...<p>标题(BT):我是测试</p><span>时间(Atime):2012-03-01 08:00:00</span> 你先把解析出来的数组$arr 打印出来,参考数组结构 按下面的方法调用就行了<?php$json='{"CC":0,"Atime":"2012-03-01 08:00:00","class":{"cId":1,"cname":"ceshi","cer":"jia","csum":014,"cpic":"http://127.0.0.1/s-001.png"},"comment":"0121","commentCount":1,"fId":01432,"Create":"2012-03-01 15:31:10","id":001,"BCount":0,"Bitem":{"BId":001,"Bd":01001,"Bpic":"http://127.0.0.1/B001.jpg","Bp":12,"BUID":124,"BT":"我是测试"},"BUrl":"http://127.0.0.1","BOT":{"OID":02002,"OCI":12451,"BCTime":"2012-03-01 15:31:17"},"PRI":"PUBLIC","SER":{"FPIC":"http://127.0.0.1/001.png","SId":454291526,"SName":"","SCK":"admin","Sum":8},"SCE":"RATE","STA":"TOP","UPtime":"2012-02-28 10:03:55","click":3}';$json=preg_replace('/(\:)([^\:",\}\s]*?)([,|\}]{1})/','$1"$2"$3',$json);$arr=json_decode($json,true);echo "<p>标题(BT):{$arr['Bitem']['BT']}</p>";echo "<span>时间(Atime):{$arr['Atime']}</span>";?> foreach 遍历数组将数组内需要的元素给输出即可.参考楼上不懂的话学习一下数组循环输出等基础知识 基础问题,怎么回事 php与form问题,input同名只传一个值 php怎么替换大于5位数的数字为<img src="tar.php?=12345" width="709" height="29" /> 用php向ftp上传文件 花小钱请哪位大哥做个DZ远程附件发表时自动上传 php header重定向的时候能带参数吗? 终于开了,盼了好多天了,怎么颜色感觉怪怪的 如何返回file.txt文本文件的行数? 我也来散点分吧!中秋快乐! telnet send命令怎么写 PHP编辑的问题 PHP 5.3.10 在Windows系统下的一个Bug
$json='{
"CC": 0,
"Atime": "2012-03-01 08:00:00",
"class": {
"cId": 1,
"cname": "ceshi",
"cer": "jia",
"csum": 014,
"cpic": "http://127.0.0.1/s-001.png"
},
"comment": "0121",
"commentCount": 1,
"fId": 01432,
"Create": "2012-03-01 15:31:10",
"id": 001,
"BCount": 0,
"Bitem": {
"BId": 001,
"Bd": 01001,
"Bpic": "http://127.0.0.1/B001.jpg",
"Bp": 12,
"BUID": 124,
"BT": "我是测试"
},
"BUrl": "http://127.0.0.1",
"BOT": {
"OID": 02002,
"OCI": 12451,
"BCTime": "2012-03-01 15:31:17"
},
"PRI": "PUBLIC",
"SER": {
"FPIC": "http://127.0.0.1/001.png",
"SId": 454291526,
"SName": "",
"SCK": "admin",
"Sum": 8
},
"SCE": "RATE",
"STA": "TOP",
"UPtime": "2012-02-28 10:03:55",
"click": 3
}';
$json=preg_replace('/\:\s+([^"\}]*?),\}?/',': "$1",',$json);
print_r(json_decode($json,true));
?>
<?php
$json='{"CC":0,"Atime":"2012-03-01 08:00:00","class":{"cId":1,"cname":"ceshi","cer":"jia","csum":014,"cpic":"http://127.0.0.1/s-001.png"},"comment":"0121","commentCount":1,"fId":01432,"Create":"2012-03-01 15:31:10","id":001,"BCount":0,"Bitem":{"BId":001,"Bd":01001,"Bpic":"http://127.0.0.1/B001.jpg","Bp":12,"BUID":124,"BT":"我是测试"},"BUrl":"http://127.0.0.1","BOT":{"OID":02002,"OCI":12451,"BCTime":"2012-03-01 15:31:17"},"PRI":"PUBLIC","SER":{"FPIC":"http://127.0.0.1/001.png","SId":454291526,"SName":"","SCK":"admin","Sum":8},"SCE":"RATE","STA":"TOP","UPtime":"2012-02-28 10:03:55","click":3}';
$json=preg_replace('/\s/','',$json);
$json=preg_replace('/\:\s*([^"\}]*?),\}?/',': "$1",',$json);
print_r(json_decode($json,true));
?>
非常感谢!
我没说清楚,实在不好意思,我要单独调用一些的,因为我还要排版...
<p>标题(BT):我是测试</p>
<span>时间(Atime):2012-03-01 08:00:00</span>
<?php
$json='{"CC":0,"Atime":"2012-03-01 08:00:00","class":{"cId":1,"cname":"ceshi","cer":"jia","csum":014,"cpic":"http://127.0.0.1/s-001.png"},"comment":"0121","commentCount":1,"fId":01432,"Create":"2012-03-01 15:31:10","id":001,"BCount":0,"Bitem":{"BId":001,"Bd":01001,"Bpic":"http://127.0.0.1/B001.jpg","Bp":12,"BUID":124,"BT":"我是测试"},"BUrl":"http://127.0.0.1","BOT":{"OID":02002,"OCI":12451,"BCTime":"2012-03-01 15:31:17"},"PRI":"PUBLIC","SER":{"FPIC":"http://127.0.0.1/001.png","SId":454291526,"SName":"","SCK":"admin","Sum":8},"SCE":"RATE","STA":"TOP","UPtime":"2012-02-28 10:03:55","click":3}';
$json=preg_replace('/(\:)([^\:",\}\s]*?)([,|\}]{1})/','$1"$2"$3',$json);
$arr=json_decode($json,true);echo "<p>标题(BT):{$arr['Bitem']['BT']}</p>";
echo "<span>时间(Atime):{$arr['Atime']}</span>";
?>