So I tried to use Chinese characters as the keys for my PHP associative array, but then when I print_r’ed the array, it printed out a whole bunch of garbage instead.
What needs to be done so that I can use Chinese characters for my PHP array keys?
Displaying chinese characters as string work fine though. It’s just when I placed them as array keys when it stops working…
eg:
$j = array();
$j[utf8_encode('大')] = 1;
$f = array_keys($j);
echo utf8_decode($f[0]);
To show case a very simple case of using Chinese character in associate key :-
Here is the example if you apply
utf8_encodeandutf8_decode:One possible way to overcome: