Home >Backend Development >PHP Tutorial >php function strspn() that returns a string containing the number of characters specified in the charlist parameter
Example
Returns the number of characters "kHlleo" contained in String "Hello world!":
<?php echo strspn("Hello world!","kHlleo"); ?>
Definition and usage
The strspn() function returns the number of characters in a string containing the number of characters specified in the charlist parameter.
Tip: Please use the strcspn() function to return the number of characters searched in a string before any specified character is found.
Note: This function is binary safe.
Syntax
strspn(string,charlist,start,length)
Parameters | Description |
string | Required. Specifies the string to be searched for. |
charlist | Required. Specifies the characters to search for. |
start | Optional. Specifies where in the string to begin. |
length | Optional. Defines the length of the string. |
Technical details
Return value: | Returns the charlist parameter contained in the string The specified number of characters. |
PHP Version: | 4+ |
##Update Log : | In PHP 4.3, new start and length parameters were added.
The above is the detailed content of php function strspn() that returns a string containing the number of characters specified in the charlist parameter. For more information, please follow other related articles on the PHP Chinese website!