2 /* Prototype : proto int strspn(string str, string mask [, int start [, int len]])
3 * Description: Finds length of initial segment consisting entirely of characters found in mask.
4 If start or/and length is provided works like strspn(substr($s,$start,$len),$good_chars)
5 * Source code: ext/standard/string.c
6 * Alias to functions: none
10 * Testing strspn() : with different heredoc strings as str argument
13 echo "*** Testing strspn() : with heredoc strings ***\n";
15 // initialing required variables
16 // defining different heredoc strings
17 $empty_heredoc = <<<EOT
20 $heredoc_with_newline = <<<EOT
25 $heredoc_with_characters = <<<EOT
26 first line of heredoc string
27 second line of heredoc string
28 third line of heredocstring
31 $heredoc_with_newline_and_tabs = <<<EOT
32 hello\tworld\nhello\nworld\n
35 $heredoc_with_alphanumerics = <<<EOT
40 $heredoc_with_embedded_nulls = <<<EOT
45 $heredoc_with_hexa_octal = <<<EOT
46 hello\0\100\xaaworld\0hello
50 $heredoc_strings = array(
52 $heredoc_with_newline,
53 $heredoc_with_characters,
54 $heredoc_with_newline_and_tabs,
55 $heredoc_with_alphanumerics,
56 $heredoc_with_embedded_nulls,
57 $heredoc_with_hexa_octal
60 $mask = "sfth12\ne34l567890\0\xaa\100o";
63 // loop through each element of the array for str argument
65 foreach($heredoc_strings as $str) {
66 echo "\n-- Iteration with str value as \"$str\" --\n";
67 var_dump( strspn($str,$mask) ); // with default start and len values