<? php // 中文字符截取// author : 轻风慢语// 转载请注明出处 function cutStr( $str , $len ){ $new_str = '' ; $wordLen = 0 ; while ( $wordLen < $len ) { $temp_str = substr ( $str , 0 , 1 ); if ( ord ( $temp_str ) > 127 ) { // 中文 $new_str .= substr ( $str , 0 , 3 ); $str = substr ( $str , 3 ); $wordLen ++ ;} else { // E文 $new_str .= substr ( $str , 0 , 1 ); $str = substr ( $str , 1 ); $wordLen ++ ;}} return $new_str ;} echo cutStr( " 我爱你AND他,AND大家 " , 8 ); ?>