
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
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
- Related Articles
- strcspn() in C
- filter_has_var() function in PHP
- filter_id() function in PHP
- filter_input() function in PHP
- filter_input_array() function in PHP
- filter_list() function in PHP
- filter_var_array() function in PHP
- filter_var() function in PHP
- constant() function in PHP
- define() function in PHP
- defined() function in PHP
- die() function in PHP
- eval() function in PHP
- exit() function in PHP
- get_browser() function in PHP

Advertisements