May 7, 2022
If youâre using PHPâs strlen
or mb_strlen
functions, some emojis will still be counted as multiple characters because of the way that unicode encodes emojis.
Instead, you can use the grapheme_strlen
function, which counts all emojis only as one character. It counts a stringâs length in âgraphemeâ units, which are âthe smallest functional unit of a writing system.â
PHP documentation for grapheme_strlen
can be found here.