- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strcspn() function in PHP
The strcspn() function returns the number of characters find in a string before any part of the specified characters are found.
Syntax
strcspn(str,char,begin,len)
Parameters
str − The string to search
char − The char to search
begin − Where to begin in the string
len − The length of the string
Return
The strcspn() function returns the number of characters found in a string.
The following is an example −
Example
<?php echo strcspn("demo text","m"); ?>
The following is the output −
Output
2
Let us see another example −
Example
<?php echo strcspn("Demo text!!","e",0,4); ?>
The following is the output −
Output
1
Advertisements