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

strpbrk

在字符串中查找一組字符的任何一個字符-返回一個以找到的字符開始的子字符串
名稱:strpbrk
分類:字符串
所屬語言:php
一句話介紹:在字符串中查找一組字符的任何一個字符。

實例

例子1

在字符串中搜索字符"Sh",並返回字符串中從指定字符第一次出現的位置開始的剩餘部分:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strpbrk</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">"Sh"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

例子2

該函數區分大小寫("S" 和"s" 輸出不相同):

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strpbrk</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">"S"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token string double-quoted-string">"<br>"</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">strpbrk</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">"s"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

同類函數
  • 檢查字符串是否以給定的子字符串開頭 str_starts_with

    str_starts_with

    檢查字符串是否以給定的子字符串開頭
  • strstr的別名 strchr

    strchr

    strstr的別名
  • 返回有關字符串中使用的字符的信息-統計string 中每個字節值(0..255)出現的次數 count_chars

    count_chars

    返回有關字符串中使用的字符的信息-統計s
  • 返回有關字符串中使用的單詞的信息 str_word_count

    str_word_count

    返回有關字符串中使用的單詞的信息
  • 重複一個字符串 str_repeat

    str_repeat

    重複一個字符串
  • 將數字格式化成貨幣字符串 money_format

    money_format

    將數字格式化成貨幣字符串
  • 替換字符串的子串 substr_replace

    substr_replace

    替換字符串的子串
  • 在字符串所有新行之前插入HTML 換行標記 nl2br

    nl2br

    在字符串所有新行之前插入HTML換行標記
熱門文章