php解析json数组
<?$ch=curl_init();curl_setopt($ch,CURLOPT_URL,'http://kfapp.aliapp.com/work.php');//设...
<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://kfapp.aliapp.com/work.php'); //设置url
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //设置开启重定向支持
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch); //执行
curl_close($ch);
$J=json_decode($a);
//print_r($J);
for($i=0;$i<count($J->data);$i++){
echo $J->data[$i]->pindao;
echo '|';
}
?>
为什么json数组解析不出来。。。。json_decode($a)得到的是空的 展开
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://kfapp.aliapp.com/work.php'); //设置url
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //设置开启重定向支持
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch); //执行
curl_close($ch);
$J=json_decode($a);
//print_r($J);
for($i=0;$i<count($J->data);$i++){
echo $J->data[$i]->pindao;
echo '|';
}
?>
为什么json数组解析不出来。。。。json_decode($a)得到的是空的 展开
2个回答
展开全部
json_last_error 查看下。
JSON_ERROR_NONE No error has occurred
JSON_ERROR_DEPTH The maximum stack depth has been exceeded
JSON_ERROR_STATE_MISMATCH Invalid or malformed JSON
JSON_ERROR_CTRL_CHAR Control character error, possibly incorrectly encoded
JSON_ERROR_SYNTAX Syntax error
JSON_ERROR_UTF8 Malformed UTF-8 characters, possibly incorrectly encoded PHP 5.3.3
JSON_ERROR_NONE No error has occurred
JSON_ERROR_DEPTH The maximum stack depth has been exceeded
JSON_ERROR_STATE_MISMATCH Invalid or malformed JSON
JSON_ERROR_CTRL_CHAR Control character error, possibly incorrectly encoded
JSON_ERROR_SYNTAX Syntax error
JSON_ERROR_UTF8 Malformed UTF-8 characters, possibly incorrectly encoded PHP 5.3.3
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询