PHP strrchr()関数
例
文字列で「world」を検索し、この位置から文字列の最後までのすべての文字を返します。
<?php
echo strrchr("Hello world!","world");
?>
定義と使用法
strrchr()関数は、別の文字列内で最後に出現する文字列の位置を検出し、この位置から文字列の最後までのすべての文字を返します。
注:この関数はバイナリセーフです。
構文
strrchr(string,char)
パラメータ値
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
char | Required. Specifies the string to find. If this is a number, it will search for the character matching the ASCII value of that number |
技術的な詳細
戻り値: | 別の文字列内で最後に出現した文字列からメイン文字列の末尾までのすべての文字を返します。文字が見つからない場合はFALSEを返します。 |
---|---|
PHPバージョン: | 4歳以上 |
変更ログ: | この関数は、PHP4.3でバイナリセーフになりました。 |
その他の例
例
文字列で「What」を検索し、この位置から文字列の最後までのすべての文字を返します。
<?php
echo strrchr("Hello world! What a beautiful day!", "What");
?>
例
文字列で「e」(101)のASCII値を検索し、この位置から文字列の末尾までのすべての文字を返します。
<?php
echo strrchr("Hello world!",101);
?>
❮PHP文字列リファレンス