0){ if([c"/> 0){ if([c">
自己实现php UTF8中文字符串截取
header("Content-type: text/html; charset=utf-8"); function my_substr($str,$begin,$length){ $i = $begin; $result=""; while($length > 0){ if([color=red]ord($str[$i])>127[/color]){ $result .= substr($str,$i,3); $i = $i+3; }else{ $result .= substr($str,$i,1); $i++; } $length--; } return $result; } $chinese = "中a国people"; echo "<br>".my_substr($chinese,0,3);