Search Results
strspn (PHP 4, PHP 5, PHP 7, PHP 8) strspn — Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask
The strspn () function returns the number of characters found in the string that contains only characters from the charlist parameter. Tip: Use the strcspn () function to return the number of characters found in a string before any part of the specified characters are found.
- Required. Specifies the characters to find
- Required. Specifies the string to search
- Optional. Defines the length of the string
Jul 11, 2025 · The strspn () function is an in-built function in PHP which finds the length of the initial segment of a string consisting entirely of characters contained within a given list of characters passed as a parameter to the function.
Oct 4, 2024 · The strspn() function is used to find the length of the initial segment of a string which matches characters from a second string.
Discover how to use the PHP strspn function with examples and detailed explanation of its syntax and parameters.
The strspn() function in PHP is used to calculate the length of the initial segment of a string that consists entirely of characters contained within a
People also ask
What is strspn() function?
How does strspn examine a string if offset is negative?
How does strcspn function work?
PHP strspn () Function Topic: PHP String Reference Prev | Next Description The strspn() function returns the number of characters present in the initial part of the string that contains only characters specified in the mask (list of allowable characters). The following table summarizes the technical details of this function.
