A grapheme is the smallest functional unit of a writing system. Graphemes can be interpreted as the smallest units of writing that correspond with sounds.
The grapheme_strlen() function in PHP is used to get the string length in grapheme units. This function does not get the byte or character's length. The grapheme_strlen function is supported in PHP 5.3.0 and higher versions.
Syntax
integer grapheme_strlen($str_string)
Parameters
grapheme_strlen() accepts only one parameter −
$str_string − The string parameter is used to measure the length of the string and it must use a UTF-8 encoding string.
Return Values
This function returns the length of the string on success or it returns False on failure.
Example
<?php // used the string "abca\xCC\x8Ao\xCC\x88a\xCC\x8A" // to find the length $integer=grapheme_strlen("abca\xCC\x8Ao\xCC\x88a\xCC\x8A\x122"); // output var_dump($integer); ?>
Output
int(8)