您好,欢迎访问一九零五行业门户网

php截取中文字符(utf-8格式)的函数

$all_len){return $str;}for($i = 0;$i {if($cur_len == $start){break;}if (ord($str[$i]) > 127){$i += 3;}else{$i += 1;}$cur_len ++;}$start_pos = $i;$temp_pos = $cur_len;for(;$cur_len - $temp_pos {if($i >= $all_len)break;if (ord($str[$i]) > 127){$i += 3;}else{$i += 1;}$cur_len ++;}$end_pos = $i;return substr($str,$start_pos,$end_pos);}?>
复制代码
php自带的函数库中有很多处理字符串的函数,建议大家去深入研究下,多多实践。
其它类似信息

推荐信息