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

strspn

計算字符串中全部字符都存在於指定字符集合中的第一段子串的長度
名稱:strspn
分類:字符串
所屬語言:php
一句話介紹:返回在字符串中包含的特定字符的數目。

實例

例子1

返回在字符串"Hello world!" 中包含字符"kHlleo" 的數目:

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

親自試一試

例子2

返回在字符串"abcdefand" 中包含字符"abc" 的數目:

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">strspn</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"abcdefand"</span> <span class="token punctuation">,</span> <span class="token string double-quoted-string">"abc"</span> <span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

親自試一試

同類函數
  • 計算字符串中全部字符都存在於指定字符集合中的第一段子串的長度 strspn

    strspn

    計算字符串中全部字符都存在於指定字符集合
  • 將邏輯順序希伯來文(logical-Hebrew)轉換為視覺順序希伯來文(visual-Hebrew),並且轉換換行符 hebrevc

    hebrevc

    將邏輯順序希伯來文(logical-He
  • 反轉義一個轉義的字符串 stripslashes

    stripslashes

    反轉義一個轉義的字符串
  • 二進制安全字符串比較 strcmp

    strcmp

    二進制安全字符串比較
  • 計算指定字符串在目標字符串中最後一次出現的位置 strrpos

    strrpos

    計算指定字符串在目標字符串中最後一次出現
  • 獲取字符串長度 strlen

    strlen

    獲取字符串長度
  • 在字符串中查找一組字符的任何一個字符-返回一個以找到的字符開始的子字符串 strpbrk

    strpbrk

    在字符串中查找一組字符的任何一個字符-返
  • 根據指定格式解析輸入的字符 sscanf

    sscanf

    根據指定格式解析輸入的字符
熱門文章