utf8 substr
utf8 substr
<?php
function utf8_substr($str,$from,$len){
return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'$1',$str);
}
echo utf8_substr('người đi xa mãi',0,10);
?>
Popularity: 83% [?]
No comments yet.