怎么会有错呢,简单的json读取 看着json 不对劲。中文在json_encode 后不是这样的吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?php $pingluninfo = <<<EOT{ "title":"123", "url":"http://localhost/?p=9", "ttime":1401327899094, "sourceid":"9", "parentid":"0", "categoryid":"", "ownerid":"", "metadata":"", "comments":[ { "cmtid":"358", "ctime":1401327899094, "content":"2013年8月1日18:36:29 O(∩_∩)O~", "replyid":"0", "user":{ "userid":"1", "nickname":"admin", "usericon":"", "userurl":"", "usermetadata":{ "area": "北京市", "gender": "1", "kk": "", "level": 1 } }, "ip":"127.0.0.1", "useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0", "channeltype":"1", "from":"", "spcount":"", "opcount":"", "attachment":[ { "type":1, "desc":"", "url":"http://img.sohu.itc/xxxx" } ] } ]}EOT;$pingluninfo = json_decode($pingluninfo, true);if(!$pingluninfo) { die('错误的数据格式');}echo "<pre>";print_r($pingluninfo);echo "</pre>";输出:Array( [title] => 123 [url] => http://localhost/?p=9 [ttime] => 1401327899094 [sourceid] => 9 [parentid] => 0 [categoryid] => [ownerid] => [metadata] => [comments] => Array ( [0] => Array ( [cmtid] => 358 [ctime] => 1401327899094 [content] => 2013年8月1日18:36:29 O(∩_∩)O~ [replyid] => 0 [user] => Array ( [userid] => 1 [nickname] => admin [usericon] => [userurl] => [usermetadata] => Array ( [area] => 北京市 [gender] => 1 [kk] => [level] => 1 ) ) [ip] => 127.0.0.1 [useragent] => Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0 [channeltype] => 1 [from] => [spcount] => [opcount] => [attachment] => Array ( [0] => Array ( [type] => 1 [desc] => [url] => http://img.sohu.itc/xxxx ) ) ) ))测试无误 请把引号补齐!"ttime":1401327899094, 应为 "ttime":"1401327899094",其他类同 echo '<meta http-equiv="content-type" content="text/html;charset=utf-8">';$pingluninfo = <<<EOT{ "title":"123", "url":"http://localhost/?p=9", "ttime":1401327899094, "sourceid":"9", "parentid":"0", "categoryid":"", "ownerid":"", "metadata":"", "comments":[ { "cmtid":"358", "ctime":1401327899094, "content":"2013年8月1日18:36:29 O(∩_∩)O~", "replyid":"0", "user":{ "userid":"1", "nickname":"admin", "usericon":"", "userurl":"", "usermetadata":{ "area": "北京市", "gender": "1", "kk": "", "level": 1 } }, "ip":"127.0.0.1", "useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0", "channeltype":"1", "from":"", "spcount":"", "opcount":"", "attachment":[ { "type":1, "desc":"", "url":"http://img.sohu.itc/xxxx" } ] } ]}EOT;$pingluninfo = json_decode($pingluninfo, true);if(!$pingluninfo) { die('错误的数据格式');}else{ print_r($pingluninfo);}测试过,很正常。( [title] => 123 [url] => http://localhost/?p=9 [ttime] => 1401327899094 [sourceid] => 9 [parentid] => 0 [categoryid] => [ownerid] => [metadata] => [comments] => Array ( [0] => Array ( [cmtid] => 358 [ctime] => 1401327899094 [content] => 2013年8月1日18:36:29 O(∩_∩)O~ [replyid] => 0 [user] => Array ( [userid] => 1 [nickname] => admin [usericon] => [userurl] => [usermetadata] => Array ( [area] => 北京市 [gender] => 1 [kk] => [level] => 1 ) ) [ip] => 127.0.0.1 [useragent] => Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0 [channeltype] => 1 [from] => [spcount] => [opcount] => [attachment] => Array ( [0] => Array ( [type] => 1 [desc] => [url] => http://img.sohu.itc/xxxx ) ) ) )) php函数优先级问题 请教一下如何获得日本的日期 时间 与星期 求高手帮忙改下批量删除 问问有经验的朋友,频繁处理数据库里的数据,是提交数据库服务器用处理快,还是在本地处理比较快 php与mysql的连接,怎么回事 类似新浪的消息主动推送到客户端怎么实现的? 给大家提供一份关于replace执行效率的测试 PostgreSQL8.0正式版昨天发布,散分留念 临时表加limit的分页问题 当我需要高精度位运算时,遇到溢出该怎么解决?谢谢帮忙,我把自己能给的分都给了。。 系统服务和非系统服务有何区别 谁能解释下这个下载
<?php
$pingluninfo = <<<EOT
{
"title":"123",
"url":"http://localhost/?p=9",
"ttime":1401327899094,
"sourceid":"9",
"parentid":"0",
"categoryid":"",
"ownerid":"",
"metadata":"",
"comments":[
{
"cmtid":"358",
"ctime":1401327899094,
"content":"2013年8月1日18:36:29 O(∩_∩)O~",
"replyid":"0",
"user":{
"userid":"1",
"nickname":"admin",
"usericon":"",
"userurl":"",
"usermetadata":{
"area": "北京市",
"gender": "1",
"kk": "",
"level": 1
}
},
"ip":"127.0.0.1",
"useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0",
"channeltype":"1",
"from":"",
"spcount":"",
"opcount":"",
"attachment":[
{
"type":1,
"desc":"",
"url":"http://img.sohu.itc/xxxx"
}
]
}
]
}
EOT;$pingluninfo = json_decode($pingluninfo, true);
if(!$pingluninfo) {
die('错误的数据格式');
}
echo "<pre>";
print_r($pingluninfo);
echo "</pre>";
输出:Array
(
[title] => 123
[url] => http://localhost/?p=9
[ttime] => 1401327899094
[sourceid] => 9
[parentid] => 0
[categoryid] =>
[ownerid] =>
[metadata] =>
[comments] => Array
(
[0] => Array
(
[cmtid] => 358
[ctime] => 1401327899094
[content] => 2013年8月1日18:36:29 O(∩_∩)O~
[replyid] => 0
[user] => Array
(
[userid] => 1
[nickname] => admin
[usericon] =>
[userurl] =>
[usermetadata] => Array
(
[area] => 北京市
[gender] => 1
[kk] =>
[level] => 1
) ) [ip] => 127.0.0.1
[useragent] => Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0
[channeltype] => 1
[from] =>
[spcount] =>
[opcount] =>
[attachment] => Array
(
[0] => Array
(
[type] => 1
[desc] =>
[url] => http://img.sohu.itc/xxxx
) ) ) ))测试无误
"ttime":1401327899094, 应为 "ttime":"1401327899094",
其他类同
echo '<meta http-equiv="content-type" content="text/html;charset=utf-8">';$pingluninfo = <<<EOT
{
"title":"123",
"url":"http://localhost/?p=9",
"ttime":1401327899094,
"sourceid":"9",
"parentid":"0",
"categoryid":"",
"ownerid":"",
"metadata":"",
"comments":[
{
"cmtid":"358",
"ctime":1401327899094,
"content":"2013年8月1日18:36:29 O(∩_∩)O~",
"replyid":"0",
"user":{
"userid":"1",
"nickname":"admin",
"usericon":"",
"userurl":"",
"usermetadata":{
"area": "北京市",
"gender": "1",
"kk": "",
"level": 1
}
},
"ip":"127.0.0.1",
"useragent":"Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0",
"channeltype":"1",
"from":"",
"spcount":"",
"opcount":"",
"attachment":[
{
"type":1,
"desc":"",
"url":"http://img.sohu.itc/xxxx"
}
]
}
]
}
EOT;$pingluninfo = json_decode($pingluninfo, true);
if(!$pingluninfo) {
die('错误的数据格式');
}else{
print_r($pingluninfo);
}测试过,很正常。(
[title] => 123
[url] => http://localhost/?p=9
[ttime] => 1401327899094
[sourceid] => 9
[parentid] => 0
[categoryid] =>
[ownerid] =>
[metadata] =>
[comments] => Array
(
[0] => Array
(
[cmtid] => 358
[ctime] => 1401327899094
[content] => 2013年8月1日18:36:29 O(∩_∩)O~
[replyid] => 0
[user] => Array
(
[userid] => 1
[nickname] => admin
[usericon] =>
[userurl] =>
[usermetadata] => Array
(
[area] => 北京市
[gender] => 1
[kk] =>
[level] => 1
) ) [ip] => 127.0.0.1
[useragent] => Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0
[channeltype] => 1
[from] =>
[spcount] =>
[opcount] =>
[attachment] => Array
(
[0] => Array
(
[type] => 1
[desc] =>
[url] => http://img.sohu.itc/xxxx
) ) ) ))