PHP implements the Chinese and numeric instances in the filter string,
This example describes the PHP implementation of the filter string in Chinese and numbers. Share to everyone for your reference. The implementation method is as follows:
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); $str 1=trim ($STR); if (Ord ($STR) >0xa0) { $tmpstr. = substr ($string, $i, $codelength); $i = $i + $codelength-1; } } return $TMPSTR;}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1039199.html www.bkjia.com true http://www.bkjia.com/PHPjc/1039199.html techarticle PHP implements the filter string in Chinese and numeric instances, this article describes the PHP implementation of the filter string in Chinese and numbers. Share to everyone for your reference. The concrete implementation method is as follows: ...