(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
grapheme_stristr — 從 haystack 字串中第一次出現不區分大小寫的 needle 的位置開始,返回 haystack 字串的其餘部分。
程序式風格
從 haystack 字串中第一個出現的 $needle 位置(不區分大小寫)開始,回傳包含 $needle 到 haystack 結尾的部份字串。
haystack輸入的字串。必須是有效的 UTF-8 編碼。
needle要搜尋的字串。必須是有效的 UTF-8 編碼。
beforeNeedle如果為 true,grapheme_stristr() 會回傳 haystack 中,第一個出現 needle 之前的部份字串(不包含 needle)。
回傳 haystack 的部份字串,如果找不到 needle 則回傳 false。
範例 #1 grapheme_stristr() 範例
<?php
$char_a_ring_nfd = "a\xCC\x8A"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) 正規化格式 "D"
$char_o_diaeresis_nfd = "o\xCC\x88"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) 正規化格式 "D"
$char_O_diaeresis_nfd = "O\xCC\x88"; // 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) 正規化格式 "D"
print urlencode(grapheme_stristr( $char_a_ring_nfd . $char_o_diaeresis_nfd . $char_a_ring_nfd, $char_O_diaeresis_nfd));
?>上述範例會輸出
o%CC%88a%CC%8A