PHPでのutf-8文字列の長さを取得するコード
サンプルコード:
function utf8_strlen($string){
$string=trim($string);
if(empty($string)) return 0;
preg_match_all(“/./us", $string, $match);
return count($match[0]);
}
Coding Changes the World
サンプルコード:
function utf8_strlen($string){
$string=trim($string);
if(empty($string)) return 0;
preg_match_all(“/./us", $string, $match);
return count($match[0]);
}