CakeFest 2024: The Official CakePHP Conference

grapheme_strstr

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

grapheme_strstrhaystack 文字列の中で、needle が最初に登場した場所以降の部分文字列を返す

説明

手続き型

grapheme_strstr(string $haystack, string $needle, bool $beforeNeedle = false): string|false

haystack 文字列の中で needle が最初に登場した場所を含めてそれ以降の部分文字列を返します。

パラメータ

haystack

入力文字列。正しい形式の UTF-8 でなければなりません。

needle

探したい文字列。正しい形式の UTF-8 でなければなりません。

beforeNeedle

true の場合、grapheme_strstr()needle が最初に登場した場所より前の haystack の部分文字列を返します (needle は含めません)。

戻り値

haystack の部分文字列、あるいは needle が見つからなかった場合に false を返します。

例1 grapheme_strstr() の例

<?php

$char_a_ring_nfd
= "a\xCC\x8A"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd = "o\xCC\x88"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "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

参考

add a note

User Contributed Notes

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