Solution to garbled Chinese output of php array: First add the "header("Content-type:text/html;charset=utf-8");" code at the beginning of the php document; then save the php document It can be in "UTF-8" format.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php array Chinese output garbled code
<?php $arr1 =array("a"=>"猫","b"=>"狗","c"=>"兔子"); var_dump($arr1); ?>
Output:
array (size=3) 'a' => string '鐚�' (length=3) 'b' => string '鐙�' (length=3) 'c' => string '鍏斿瓙' (length=6)
Solution:
Add the following code at the beginning of the php page, and then save the UTF -8 encoded files are sufficient.
header("Content-type:text/html;charset=utf-8");
Output at this time:
array (size=3) 'a' => string '猫' (length=3) 'b' => string '狗' (length=3) 'c' => string '兔子' (length=6)
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if the Chinese output of php array is garbled?. For more information, please follow other related articles on the PHP Chinese website!