(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
grapheme_stristr — Retourne la partie d'une chaîne à partir d'une occurrence
Description
Style procédural
grapheme_stristr(string
$haystack
, string
$needle
, bool
$beforeNeedle
=
false
): string|false
Liste de paramètres
-
haystack
-
La chaîne à étudier. Elle doit être valide UTF-8.
-
needle
-
La chaîne à rechercher. Elle doit être valide UTF-8.
-
beforeNeedle
-
Si true
, grapheme_stristr() retourne la
partie de haystack
avant la première occurrence (needle
exclus).
Valeurs de retour
Retourne une portion de haystack
, ou false
si needle
n'est pas trouvé.
Exemples
Exemple #1 Exemple avec grapheme_stristr()
<?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"
$char_O_diaeresis_nfd = "O\xCC\x88"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) forme normalisée "D"
print urlencode(grapheme_stristr( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_a_ring_nfd, $char_O_diaeresis_nfd));
?>
L'exemple ci-dessus va afficher :
o%CC%88a%CC%8A
Voir aussi
- grapheme_stripos() - Trouve la position en graphème de la première occurrence dans une chaîne, insensible à la casse
- grapheme_strpos() - Trouve la position du premier graphème
- grapheme_strripos() - Trouve la position du dernier graphème, insensible à la casse
- grapheme_strrpos() - Trouve la position du dernier graphème
- grapheme_strstr() - Retourne la partie d'une chaîne à partir d'une occurrence, insensible à la casse
-
»
Unicode Text Segmentation: Grapheme Cluster Boundaries