PHP转换字符串编码
程序员文章站
2022-05-19 19:09:52
...
php代码
<?php function phpcharset($data, $to) { if(is_array($data)) { foreach($data as $key => $val) { $data[$key] = phpcharset($val, $to); } } else { $encode_array = array('ASCII', 'UTF-8', 'GBK', 'GB2312', 'BIG5'); $encoded = mb_detect_encoding($data, $encode_array); $to = strtoupper($to); if($encoded != $to) { $data = mb_convert_encoding($data, $to, $encoded); } } return $data; } ?>
上一篇: python删除指定类型(或非指定)的文件实例详解
下一篇: xml加个节点如何写