- function chkCode($string){
- $code = array('UTF-8','GBK','GB18030','GB2312');
- foreach($code as $c){
- if( $string === iconv('UTF-8', $c, iconv($c, 'UTF-8', $string))){
- return $c;
- }
- }
- return "no";
- }
- $file1 = 'test1.txt';
- $str1 = file_get_contents($file1);
- echo chkCode("$str1");
- //该片段来自于http://www.codesnippet.cn/detail/200820135238.html
来源: http://www.codesnippet.cn/detail/200820135238.html