import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-strings / strcspn_variation11.php
blobe29b94a55050693df7fb1134077f0b52db2da500
1 <?php
2 /* Prototype : proto int strcspn(string str, string mask [, int start [, int len]])
3 * Description: Finds length of initial segment consisting entirely of characters not found in mask.
4 If start or/and length is provided works like strcspn(substr($s,$start,$len),$bad_chars)
5 * Source code: ext/standard/string.c
6 * Alias to functions: none
7 */
9 /*
10 * Testing strcspn() : with varying start and default len arguments
13 echo "*** Testing strcspn() : with different start and default len values ***\n";
15 // initialing required variables
16 // initialing required variables
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 // defining array of mask strings
38 $mask_array = array(
39 "",
40 '',
41 "\n\trsti \l",
42 '\n\trsti \l',
43 "\t",
44 "t\ ",
45 '\t',
46 "\t\ ",
47 " \t",
48 "\t\i\100\xa"
51 //defining array of 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 arguments
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( strcspn($str,$mask,$start) );
72 $count++;
75 echo "Done"