Home > Backend Development > PHP Tutorial > php转换中文编码问题

php转换中文编码问题

WBOY
Release: 2016-06-23 13:51:44
Original
1023 people have browsed it

用的是一个函数:

function array_iconv($in_charset, $out_charset, $arr){//$in_charset代表之前的编码,$out_charset代表要转成的编码,$arr代表传过来的要转换的数组

return eval('return'.iconv($in_charset, $out_charset, var_export($arr, true)));

}

解释:

先用var_export将数组$arr转换成字符串变量,然后再用iconv对该字符串变量进行中文编码转换,最后再用eval将其转换回来,得到的就是转换完的数组,其中的汉字全部被转换成指定的编码

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template