Home >php教程 >PHP源码 >PHP 自动检测编码转换

PHP 自动检测编码转换

PHP中文网
PHP中文网Original
2016-06-01 14:32:431267browse

跳至

//自动检测内容是编码进行转换 get_encoding($data,"GB2312");
function get_encoding($data,$to)
{
$encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
$encoded = mb_detect_encoding($data, $encode_arr);
$data = mb_convert_encoding($data,$to,$encoded);
return $data;
}

                   

Statement:
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
Previous article:经典冒泡排序Next article:php遍历目录