當前位置: 首頁> 函數類別大全> strrchr

strrchr

查找指定字符在字符串中的最後一次出現
名稱:strrchr
分類:字符串
所屬語言:php
一句話介紹:查找字符串在另一個字符串中最後一次出現。

實例

例子1

搜索"Shanghai" 在字符串中的位置,並返回從該位置到字符串結尾的所有字符:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strrchr</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"I love Shanghai!"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"Shanghai"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

例子2

搜索"What" 在字符串中的位置,並返回從該位置到字符串結尾的所有字符:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strrchr</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"Hello world! What a beautiful day!"</span> <span class="token punctuation">,</span> What <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

例子3

以"o" 的ASCII 值搜索"o" 在字符串中的位置,並返回從該位置到字符串結尾的所有字符:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strrchr</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"Hello world!"</span> <span class="token punctuation">,</span> <span class="token number">101</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

同類函數
  • 以C 語言風格使用反斜線轉義字符串中的字符 addcslashes

    addcslashes

    以C語言風格使用反斜線轉義字符串中的字符
  • 計算指定字符串在目標字符串中最後一次出現的位置 strrpos

    strrpos

    計算指定字符串在目標字符串中最後一次出現
  • 將字符串轉化為大寫 strtoupper

    strtoupper

    將字符串轉化為大寫
  • 輸出格式化的字符串 printf

    printf

    輸出格式化的字符串
  • 將特殊的HTML 實體轉換回普通字符 htmlspecialchars_decode

    htmlspecialchars_decode

    將特殊的HTML實體轉換回普通字符
  • 轉義元字符集 quotemeta

    quotemeta

    轉義元字符集
  • 返回字符串的一部分 substr

    substr

    返回字符串的一部分
  • 將字符由一種Cyrillic 字符轉換成另一種 convert_cyr_string

    convert_cyr_string

    將字符由一種Cyrillic字符轉換成另