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
编译原理
Alfred V. Aho、Monica S.Lam、Ravi Sethi、Jeffrey D. Ullman / 赵建华、郑滔、戴新宇 / 机械工业出版社 / 2008年12月 / 89.00元
本书全面、深入地探讨了编译器设计方面的重要主题,包括词法分析、语法分析、语法制导定义和语法制导翻译、运行时刻环境、目标代码生成、代码优化技术、并行性检测以及过程间分析技术,并在相关章节中给出大量的实例。与上一版相比,本书进行了全面的修订,涵盖了编译器开发方面的最新进展。每章中都提供了大量的系统及参考文献。 本书是编译原理课程方面的经典教材,内容丰富,适合作为高等院校计算机及相关专业本科生及研......一起来看看 《编译原理》 这本书的介绍吧!