Definition
The strspn() function returns the number of characters found in the string that contains only characters from the charlist parameter.
Syntax
strspn(string, charlist, start, length)
Parameters
Parameter | Description |
---|---|
string |
Required. Specifies the string to search. |
charlist |
Required. Specifies the characters to find. |
start |
Optional. Specifies where in the string to start. |
length |
Optional. Defines the length of the string. |
Example
<?php
echo strspn("Welcome to PHP!", "to");