Home >Backend Development >PHP Problem >How to convert php ascii to Chinese
php How to convert ascii to Chinese: First create a PHP sample file; then define an asciitostr method; then convert ascii to Chinese through functions such as "mb_convert_encoding".
Recommended: "PHP Video Tutorial"
Convert ascii to string (Chinese is also practical) (note : I default that our current php file environment is UTF-8. If it is GBK, the mb_convert_encoding operation is not needed)
public function asciitostr($sacii){ $asc_arr= str_split(strtolower($sacii),2); $str=''; for($i=0;$i<count($asc_arr);$i++){ $str.=chr(hexdec($asc_arr[$i][1].$asc_arr[$i][0])); } return mb_convert_encoding($str,'UTF-8','GB2312'); }
The above is the detailed content of How to convert php ascii to Chinese. For more information, please follow other related articles on the PHP Chinese website!