PHP strspn() 函数

PHP 教程 · 2019-01-30 11:56:34

实例

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

<?php
echo strspn("Hello world!","kHlleo");
?>

定义和用法

strspn() 函数返回在字符串中包含 charlist 参数中指定的字符数目。

提示:请使用 strcspn() 函数来返回在找到任何指定的字符之前,在字符串查找的字符数。

注释:该函数是二进制安全的。

语法


strspn(string,charlist,start,length)


参数 描述
string 必需。规定被搜索的字符串。
charlist 必需。规定要查找的字符。
start 可选。规定在字符串的何处开始。
length 可选。定义字符串的长度。

技术细节

返回值: 返回在字符串中包含 charlist 参数中指定的字符数目。
PHP 版本: 4+
更新日志: 在 PHP 4.3 中,新增了 start 和 length 参数。

更多实例

实例 1

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

<?php
echo strspn("abcdefand","abc");
?>

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Weaving the Web

Weaving the Web

Tim Berners-Lee / Harper Paperbacks / 2000-11-01 / USD 15.00

Named one of the greatest minds of the 20th century by Time , Tim Berners-Lee is responsible for one of that century's most important advancements: the world wide web. Now, this low-profile genius-wh......一起来看看 《Weaving the Web》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

SHA 加密
SHA 加密

SHA 加密工具