In PHP, what is the best way to split a string into an array of Unicode characters? If the input is not necessarily UTF-8?
I want to know whether the set of Unicode
the best way for split with length: I just changed laravel str_limit()
function:
public static function split_text($text, $limit = 100, $end = '')
{
$width=mb_strwidth($text, 'UTF-8');
if ($width <= $limit) {
return $text;
}
$res=[];
for($i=0;$i<=$width;$i=$i+$limit){
$res[]=rtrim(mb_strimwidth($text, $i, $limit, '', 'UTF-8')).$end;
}
return $res;
}