I'm trying to parse this json file in php: http://www.oref.org.il/WarningMessages/alerts.json
This file contains Hebrew letters which cause encoding problems.
My script:
$content = file_get_contents('http://www.oref.org.il/WarningMessages/alerts.json');
$json = json_decode($content);
echo $json->id;
It just won't display anything. I just get a blank page. But if I do echo $content;
it shows the json file perfectly.
Json file example:
{
"id" : "1434292591050",
"title" : "פיקוד העורף התרעה באזור ",
"data" : []
}
I've been reading few other similar problems and solutions but none of them helped fixing this problem. I've been trying to use mb_detect_encoding
and iconv
but it didn't help.
Thank you!
The file content you're getting is in UTF-16 charset. You have to convert it: