PHP - strcspn 函式



語法

strcspn(string,char,start,length)

定義和用法

它返回在找到任何指定字元之前,字串中找到的字元數。

返回值

它返回在字串中找到的字元數。

引數

序號 引數及描述
1

字串

指定要搜尋的字串。

2

字元

指定要搜尋的字元。

3

起始位置

指定在字串中的哪個位置開始搜尋。

4

長度

指定字串的長度。

示例

嘗試以下示例

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

這將產生以下結果:

4
php_function_reference.htm
廣告