Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
PHP's json_decode Returns Null?
PHP CODE:
$a = array ('x'=>'xex');
var_dump($a); //output: array(1) { ["x"]=> string(3) "xex" }
echo (json_encode($a)); //output: {"x":"xex"}
$a = array ('x'=>'xéx');
var_dump($a); //output: array(1) { ["x"]=> string(3) "xéx" }
echo (json_encode($a));
The last line of code produces no output, not even "null". Can you help me understand this behaviour?
3 Answers
- ChrisLv 76 years ago
Here's what I get: {"x":"x\u00e9x"}
The data must be in utf-8 format, which means you have to save the PHP file as Unicode, not ANSI.
If your editor doesn't support choosing the encoding, switch to one that does, like Notepad++.