PHP json_decode returns null

I'm trying to get this to work but can't see where I am going wrong. Can anyone please help?

<?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
?>

      

+3


source to share


2 answers


Hint:

The original JSON (stored in a variable $json

) does NOT validate.

Code: (FIXED)



<?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;

?>

      

It will work. :-)

+3


source


Your JSON source is not valid. You can try this validator http://jsonlint.com/



0


source







All Articles