PHP json_decode 带回空值

标签 php json file-get-contents

我正在努力让它发挥作用,但看不出哪里出了问题。有人可以帮忙吗?

<?php
    $jsonurl        =   'http://www.foxsports.com.au/internal-syndication/json/livescoreboard';
    $json           =   file_get_contents($jsonurl,0,null,null);
    $json_output    =   var_dump(json_decode($json,true)); 

    echo $json_output
?>

最佳答案

提示:

初始 JSON(存储在 $json 变量中)未验证。

代码:(固定)

<?php

$jsonurl='http://www.foxsports.com.au/internal-syndication/json/livescoreboard';
$json = file_get_contents($jsonurl,0,null,null);

$json = strip_tags(str_replace("jQuery.fs['scoreboard'].data =","",$json));

$json_output = var_dump(json_decode($json,true)); 

echo $json_output;

?>

这会起作用。 :-)

关于PHP json_decode 带回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9849562/

相关文章:

php try catch 无法正常工作

javascript - 响应式 Adwords 广告

php - 将 session cookie 重命名为 PHPSESSID 之外的其他名称

json - 如何在 swift 4 中显示子 JSON 数据?

php - HTTP/1.1 505 不支持 HTTP 版本

php - PHP file_get_contents 有限制吗?

php - bool 字段与单独表

PHP页面: No database selected issue

javascript - 将 php 变量传递给 angular

javascript - 没有得到 XMLHttpRequest 的响应