Answer the question
In order to leave comments, you need to log in
Can't execute json_decode function?
Hello!
There was a problem, I do not understand what it is!
I get json remotely using file_get_content, I try to process it, it doesn’t work, NULL is given if I output a string and everything is ok.
Tried to check for errors with json_last_error(), got a Syntax error. I took the json itself, copied it into the validator, everything is ok.
How can the problem be solved?
$city = 'Красноярск';
$url = "http://www.pony-ex.ru/autocomplete/city?term=".urlencode($city);
$content = file_get_contents($url);
print_r(json_decode($content, true));
Answer the question
In order to leave comments, you need to log in
print_r(json_decode(substr($content, 3), true));
y worked for me.
problem/solution
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question