PHP strcspn() 函数
PHP 教程
· 2019-01-30 07:43:00
实例
输出在字符串 "Hello world!" 中找到字符 "w" 之前查找的字符数:
<?php
echo strcspn("Hello world!","w");
?>
echo strcspn("Hello world!","w");
?>
定义和用法
strcspn() 函数返回在找到任何指定的字符之前,在字符串查找的字符数(包括空格)。
提示: Use the strspn() function to the number of characters found in the string that contains only characters from a specified character list.
注释: This function is binary-safe.
语法
strcspn(string,char,start,length)
| 参数 | 描述 |
|---|---|
| string | 必需。规定要搜索的字符串。 |
| char | 必需。规定要查找的字符。 |
| start | 可选。规定开始查找的位置。 |
| length | 可选。规定字符串的长度(搜索多少字符)。 |
技术细节
| 返回值: | 返回在找到任何指定的字符之前,在字符串查找的字符数。 |
|---|---|
| PHP 版本: | 4+ |
| 更新日志: | 在 PHP 4.3 中,新增了 start 和 length 参数。 |
更多实例
实例 1
使用所有的参数来输出在字符串 "Hello world!" 中找到字符 "w" 之前查找的字符数:
<?php
echo strcspn("Hello world!","w",0,6); // The start position is 0 and the length of the search string is 6.
?>
echo strcspn("Hello world!","w",0,6); // The start position is 0 and the length of the search string is 6.
?>
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
他们以为自己很厉害:12个企业管理陷阱
[法] 克里斯蒂娜•凯德朗 / 王倩 / 人民邮电出版社 / 2018-11 / 69.00元
本书讲述了震惊世界的150个企业管理失败案例,并从产品与服务定位、技术 创新、广告与营销策略、跨文化发展、融资战略到企业文化与员工管理等众多角度, 揭露了商场各种败局的内幕。作者以风趣的笔触讲述了国际知名企业和商界精英们 的惨痛教训,又以专业角度解读了这些失利背后的经济学和管理学因素,给读者带 来了启示。一起来看看 《他们以为自己很厉害:12个企业管理陷阱》 这本书的介绍吧!