无涯教程-PHP - strcspn函数

70 阅读1分钟

strcspn - 语法

strcspn(string,char,start,length)

它返回在找到指定字符的任何部分之前在字符串中找到的字符数。

Sr.No 参数 & 描述
1

string

它指定要搜索的字符串

2

char

它指定要搜索的字符

3

start

它指定字符串中开始的位置

4

length

它指定字符串的长度

strcspn - 返回值

它返回在字符串中找到的字符数

strcspn - 示例

<?php
   echo strcspn("learnfk simply easy learning","r");
?>

这将产生以下输出-

4

参考链接

www.learnfk.com/php/php-fun…