grapheme_strlen

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

grapheme_strlenLit la taille d'une chaîne en nombre de graphème

Description

Style procédural

grapheme_strlen(string $string): int|false|null

Lit la taille d'une chaîne en nombre de graphème (et non pas en octets ou caractères).

Liste de paramètres

string

La chaîne à mesurer. Elle doit être une chaîne UTF-8 valide.

Valeurs de retour

La taille de la chaîne en cas de succès, ou false si une erreur survient.

Exemples

Exemple #1 Exemple avec grapheme_strlen()

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) forme normalisée "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) forme normalisée "D"

print grapheme_strlen'abc' $char_a_ring_nfd $char_o_diaeresis_nfd $char_a_ring_nfd);

?>

L'exemple ci-dessus va afficher :

6

Voir aussi

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top