Getting hebrew json to php file -


i'm trying parse json file in php: http://www.oref.org.il/warningmessages/alerts.json

this file contains hebrew letters 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 won't display anything. blank page. if echo $content; shows json file perfectly.

json file example:

{  "id" : "1434292591050", "title" : "פיקוד העורף התרעה  באזור ", "data" : [] } 

i've been reading few other similar problems , solutions none of them helped fixing problem. i've been trying use mb_detect_encoding , iconv didn't help.

thank you!

the file content you're getting in utf-16 charset. have convert it:

$content = file_get_contents('http://www.oref.org.il/warningmessages/alerts.json');  $content=iconv("utf-16", "utf-8", $content); $json = json_decode($content,true); print_r($json); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -