The phpstrcspn () function returns the number of characters (including spaces) searched in the string before any specified character is found ). This article introduces the usage and examples of phpstrcspns to coders. if you need them, refer to this article. Definition and usage
The strcspn () function returns the number of characters (including spaces) to be searched in the string before any specified characters are found ).
Tip: Use the strspn () function to return the number of characters in the string that contain the specified character list.
Note: This function is binary secure.
Syntax
strcspn(string,char,start,length)
Parameters |
Description |
String |
Required. Specifies the string to be searched. |
Char |
Required. Specifies the characters to be searched. |
Start |
Optional. Specifies where to start searching in the string. |
Length |
Optional. Specifies the length of the string (the number of characters to search ). |
Return value
Return value: |
Returns the number of characters found in the string before any part of the specified character is found. |
PHP version: |
4 + |
Update Log: |
In PHP 4.3StartAndLengthParameters. |
Instance
"; // Output in the string" Hello world! The number of characters found before the character "w": echo strcspn ("Hello world! "," W ");?>
Online operation