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

stristr

不區分大小寫的strstr
名稱:stristr
分類:字符串
所屬語言:php
一句話介紹:查找字符串在另一字符串中第一次出現的位置(大小寫不敏感)。

實例

例子1

查找"world" 在"Hello world!" 中的第一次出現,並返回字符串的剩餘部分:

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

親自試一試

例子2

以"o" 的ASCII 值搜索字符串,並返回字符串的剩餘部分:

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

親自試一試

例子2

返回"world" 第一次出現之前的字符串部分:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">stristr</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"Hello world!"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"WORLD"</span> <span class="token punctuation">,</span> <span class="token constant boolean">true</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

同類函數
  • 將數字格式化成貨幣字符串 money_format

    money_format

    將數字格式化成貨幣字符串
  • 隨機打亂一個字符串 str_shuffle

    str_shuffle

    隨機打亂一個字符串
  • 將字符串轉化為大寫 strtoupper

    strtoupper

    將字符串轉化為大寫
  • 查詢語言和區域設置信息 nl_langinfo

    nl_langinfo

    查詢語言和區域設置信息
  • strstr的別名 strchr

    strchr

    strstr的別名
  • 反引用一個使用addcslashes() 轉義的字符串 stripcslashes

    stripcslashes

    反引用一個使用addcslashes()
  • 計算字符串中全部字符都存在於指定字符集合中的第一段子串的長度 strspn

    strspn

    計算字符串中全部字符都存在於指定字符集合
  • 計算指定字符串在目標字符串中最後一次出現的位置(不區分大小寫) strripos

    strripos

    計算指定字符串在目標字符串中最後一次出現