當前位置: 首頁> 函數類別大全> 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>

親自試一試

同類函數
  • 計算文件的sha1哈希值 sha1_file

    sha1_file

    計算文件的sha1哈希值
  • 替換字符串的子串 substr_replace

    substr_replace

    替換字符串的子串
  • 二進制安全不區分大小寫的字符串比較 strcasecmp

    strcasecmp

    二進制安全不區分大小寫的字符串比較
  • 二進制安全比較字符串(從偏移位置比較指定長度) substr_compare

    substr_compare

    二進制安全比較字符串(從偏移位置比較指定
  • strstr的別名 strchr

    strchr

    strstr的別名
  • 計算字符串中全部字符都存在於指定字符集合中的第一段子串的長度 strspn

    strspn

    計算字符串中全部字符都存在於指定字符集合
  • 二進制安全字符串比較 strcmp

    strcmp

    二進制安全字符串比較
  • 從字符串中刪除HTML和PHP標記 strip_tags

    strip_tags

    從字符串中刪除HTML和PHP標記
熱門文章