- function arr_split_zh( $tempaddtext ){
- $tempaddtext = iconv( "UTF-8" , "gb2312" , $tempaddtext );
- $cind = 0;
- $arr_cont = array ();
- for ( $i =0; $i < strlen ( $tempaddtext ); $i ++)
- {
- if ( strlen ( substr ( $tempaddtext , $cind ,1)) > 0){
- if (ord( substr ( $tempaddtext , $cind ,1)) < 0xA1 ){ //如果为英文则取1个字节
- array_push ( $arr_cont , substr ( $tempaddtext , $cind ,1));
- $cind ++;
- }else {
- array_push ( $arr_cont , substr ( $tempaddtext , $cind ,2));
- $cind +=2;
- }
- }
- }
- foreach ( $arr_cont as & $row )
- {
- $row =iconv( "gb2312" , "UTF-8" , $row );
- }
- return $arr_cont ;
- }
【转】正确拆分中英文混合字符串的函数
最新推荐文章于 2023-01-29 10:04:28 发布