strlen() function in php could not return correctly string lenght of utf8 chars, for example ???? is 4 char but after using strlen thats return 8 chr
strlen()
????
<?php echo strlen('????'); ?>
The core PHP string functions all assume 1 character = 1 byte. They have no concept of different encodings. To figure out how many characters are in a UTF-8 string (not how many bytes), use the mb_strlen equivalent and tell it what encoding the string is in:
mb_strlen
echo mb_strlen('????', 'UTF-8');
1.4m articles
1.4m replys
5 comments
57.0k users