Group Searching

strspn($s1,$s2[,$i1[,$i2]]) returns the position of the first character in $s1 that cannot be found in $s2. $i1 is the position to start searching. If $i1 is negative, then the function will start searching at $i -th position from the end. $i2 is the length of the segment to examine. If $i2 is negative, $s1 will be examined from $i1 up to $i2 characters from the end. strcspn(……) is similar but returns the position of the first character in $s1 that can be found in $s2.

<!DOCTYPE html><html><head></head>
<body><?php

$s = 'I say it is quite fun to learn funny PHP at 3am.';
echo strlen($s)."<br />";
echo str_word_count($s)."<br />";
print_r(str_word_count($s,1)); echo "<br />";
print_r(str_word_count($s,2,'3')); echo "<br />";
echo substr_count($s,'fun')."<br />";
echo count_chars($s,3)."<br />";
print_r(count_chars($s,1)); echo "<br />";
echo strspn($s,'Is ')."<br />";
echo strcspn($s,'qt');

?></body></html>

48
12
Array ( [0] => I [1] => say [2] => it [3] => is [4] => quite [5] => fun [6] => to [7] => learn [8] => funny [9] => PHP [10] => at [11] => am )
Array ( [0] => I [2] => say [6] => it [9] => is [12] => quite [18] => fun [22] => to [25] => learn [31] => funny [37] => PHP [41] => at [44] => 3am )
2
.3HIPaefilmnoqrstuy
Array ( [32] => 11 [46] => 1 [51] => 1 [72] => 1 [73] => 1 [80] => 2 [97] => 4 [101] => 2 [102] => 2 [105] => 3 [108] => 1 [109] => 1 [110] => 4 [111] => 1 [113] => 1 [114] => 1 [115] => 2 [116] => 4 [117] => 3 [121] => 2 )
3
7