PHP json_decode带回null
发布时间:2020-12-13 17:11:21 所属栏目:PHP教程 来源:网络整理
导读:我试图让这个工作,但无法看到我出错的地方.有人可以帮忙吗? ?php $jsonurl = 'http://www.foxsports.com.au/internal-syndication/json/livescoreboard'; $json = file_get_contents($jsonurl,null,null); $json_output = var_dump(json_decode($json,true)
我试图让这个工作,但无法看到我出错的地方.有人可以帮忙吗?
<?php $jsonurl = 'http://www.foxsports.com.au/internal-syndication/json/livescoreboard'; $json = file_get_contents($jsonurl,null,null); $json_output = var_dump(json_decode($json,true)); echo $json_output ?> 解决方法
提示:
初始JSON(存储在$json变量中)不验证. 代码:(FIXED) <?php $jsonurl='http://www.foxsports.com.au/internal-syndication/json/livescoreboard'; $json = file_get_contents($jsonurl,null); $json = strip_tags(str_replace("jQuery.fs['scoreboard'].data =","",$json)); $json_output = var_dump(json_decode($json,true)); echo $json_output; ?> 这会奏效. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |