function getChinese($string,$encode="GBK") { switch($encode){ case "GBK" :$codelength=2;break; case "GB2312" :$codelength=3;break; case "UTF-8" :$codelength=3;break; case "UTF-16" :$codelength=4;break; } $tmpstr = ''; $arr = array(1,2,3,4,5,6,7,8,9,0); $strlen = strlen($string); for($i=0; $i<$strlen; $i++) { $str=substr($string, $i, 1); $str1=trim($str); if( ord($str)>0xA0 ){ $tmpstr.= substr($string, $i, $codelength); $i = $i+$codelength-1; } } return $tmpstr; }
希望本文所述对大家的php程序设计有所帮助。
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群