The strcspn() function is a built-in function in PHP. The syntax is strcspn(string,char,start,length). It is used to return the number of characters (including spaces) found in the string before any specified characters are found. . This function is case-sensitive.
php How to use strcspn() function?
The strcspn() function returns the number of characters (including spaces) searched in the string before any specified character is found.
Syntax:
strcspn(string,char,start,length)
Parameters:
● string: required. Specifies the string to search for.
●Char: required. Specifies the characters to search for.
● start: optional. Specifies the location to start the search.
●length: optional. Specifies the length of the string (how many characters to search for).
Return value:Returns the number of characters (including spaces) found in the string before any specified characters are found.
Let’s take a look at how to use the php strcspn() function through an example.
php strcspn() function example 1:
Output:
6
php strcspn() function example 1:
Output:
9
The above is the detailed content of How to use php strcspn function?. For more information, please follow other related articles on the PHP Chinese website!