import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strspn_variation11.php
blob529cfcffe6dfe6f192bae99c0e0fa7d46b54d1ff
1 <?php
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
7 */
9 /*
10 * Testing strspn() : with varying start and default len arguments
13 echo "*** Testing strspn() : with different start and default len values ***\n";
15 // initialing required variables
16 // defining different strings
17 $strings = array(
18 "",
19 '',
20 "\n",
21 '\n',
22 "hello\tworld\nhello\nworld\n",
23 'hello\tworld\nhello\nworld\n',
24 "1234hello45world\t123",
25 '1234hello45world\t123',
26 "hello\0world\012",
27 'hello\0world\012',
28 chr(0).chr(0),
29 chr(0)."hello\0world".chr(0),
30 chr(0).'hello\0world'.chr(0),
31 "hello".chr(0)."world",
32 'hello'.chr(0).'world',
33 "hello\0\100\xaaaworld",
34 'hello\0\100\xaaaworld'
37 // define the array of mask strings
38 $mask_array = array(
39 "",
40 '',
41 "f\n\trelshti \l",
42 'f\n\trelsthi \l',
43 "\telh",
44 "t\ ",
45 '\telh',
46 "felh\t\ ",
47 " \t",
48 "fhel\t\i\100\xa"
51 // defining the array for start values
52 $start_array = array(
56 -1,
57 -2,
58 2147483647, // max positive integer
59 -2147483648, // min negative integer
63 // loop through each element of the arrays for str, mask and start argument
64 $count = 1;
65 foreach($strings as $str) {
66 echo "\n-- Iteration $count --\n";
67 foreach($mask_array as $mask) {
68 foreach($start_array as $start) {
69 var_dump( strspn($str,$mask,$start) );
72 $count++;
75 echo "Done"