English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Character String Functions Manual
The strcspn() function returns the number of characters found in the string before finding any specified character (including spaces).
strcspn(string,char,start,length)
It returns the number of characters found in the string before finding any part of the specified character.
It returns the number of characters found in the string
Serial Number | Parameters and Description |
---|---|
1 | string It specifies the string to search for |
2 | char It specifies the characters to search for |
3 | start It specifies where to start in the string |
4 | length It specifies the length of the string |
Try the following example, output in the string "www.oldtoolbag.com!" found the character "o" before the search character count:
<?php //in the string "www.oldtoolbag.com!" found the character "o" before the search character count echo strcspn("www.oldtoolbag.com!","o"); echo '<br>'; //The starting position is 0, the length of the search string is6. echo strcspn("Hello world!","w",0,6); ?>Test and see‹/›
Output Result
6 6