mb_strlen
only gives number of bytes,not what I wanted.
It should work with multibyte characters.
mb_strlen
only gives number of bytes,not what I wanted.
It should work with multibyte characters.
mb_strlen the string being measured for length.
<?php
$str = 'abcdef';
echo strlen($str); // 6
$str = ' ab cd ';
echo strlen($str); // 7
?>
Directly from the documentation.
If you are using UTF-8 encoding step thru all bytes in string and count the chars which have the 8th bit NOT set.
This solution does not need the mb extension.
I am not sure about mb_strlen, but I use just plain old strlen myself... http://php.net/manual/en/function.strlen.php