I had previously asked the same question. I would like to decode the json from: http://ift.tt/1F5e3bs. Below is the code I used previously:
<?php
$html=file_get_contents("http://ift.tt/1F5e3bs");
var_dump(json_decode($html,true)); //return null
var_dump(json_last_error()); // return 4
?>
From the last answer I know there is UTF8 DOM in the json return. I tried the answer from a similar question: json_decode returns NULL after webservice call, but all of the answers not work for me.
And after do more research I found a way that works:
<?php
$html=file_get_contents("http://ift.tt/1F5e3bs");
$html=preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $html);
var_dump(json_decode($html, true));
var_dump(json_last_error());
?>
This successfully decode the json into array. However all Chinese and Japanese character string were removed too. Any ideas?
Aucun commentaire:
Enregistrer un commentaire