September 2001
Intermediate to advanced
768 pages
32h 45m
English
int strspn(string string, string mask)
Finds the length of the initial substring containing only characters from mask.
Returns:
Number of characters found
Description:
strspn() returns the length of the substring at the start of string that contains only characters from mask . Given string abcdef and mask abc, for example, the function returns 3.
Version:
PHP 3.0.3+, PHP 4+
See also:
To return the number of characters present in a string before any of a set of specified characters is found:
strcspn()
Example:
<?php
$list = array ("Andrew", "Brigitte", "Chris", "Deb");
foreach ($list as $name) {
if (strspn ($name, 'aeiouyAEIOUY')) {
echo $name, "\n";
}
}
?>
Output:
Andrew
|
Read now
Unlock full access