import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / array_intersect_variation3.php
blob81c9f21e2571447b3c6b51e573daa34b5b877573
1 <?php
2 /* Prototype : array array_intersect(array $arr1, array $arr2 [, array $...])
3 * Description: Returns the entries of arr1 that have values which are present in all the other arguments
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Passing different types of arrays to $arr1 argument and testing whether
9 * array_intersect() behaves in expected way with the other arguments passed to the function
10 * The $arr2 argument is a fixed array.
13 echo "*** Testing array_intersect() : Passing different types of arrays to \$arr1 argument ***\n";
15 /* Different heredoc strings passed as argument to $arr1 */
16 // heredoc with blank line
17 $blank_line = <<<EOT
20 EOT;
22 // heredoc with multiline string
23 $multiline_string = <<<EOT
24 hello world
25 The big brown fox jumped over;
26 the lazy dog
27 This is a double quoted string
28 EOT;
30 // heredoc with diferent whitespaces
31 $diff_whitespaces = <<<EOT
32 hello\r world\t
33 1111\t\t != 2222\v\v
34 heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces
35 EOT;
37 // heredoc with quoted strings and numeric values
38 $numeric_string = <<<EOT
39 11 < 12. 123 >22
40 'single quoted string'
41 "double quoted string"
42 2222 != 1111.\t 0000 = 0000\n
43 EOT;
45 // arrays to be passed to $arr1 argument
46 $arrays = array (
47 /*1*/ array(1, 2), // array with default keys and numeric values
48 array(1.1, 2.2), // array with default keys & float values
49 array(false,true), // array with default keys and boolean values
50 array(), // empty array
51 /*5*/ array(NULL), // array with NULL
52 array("a\v\f","aaaa\r","b","b\tbbb","c","\[\]\!\@\#\$\%\^\&\*\(\)\{\}"), // array with double quoted strings
53 array('a\v\f','aaaa\r','b','b\tbbb','c','\[\]\!\@\#\$\%\^\&\*\(\)\{\}'), // array with single quoted strings
54 array($blank_line, $multiline_string, $diff_whitespaces, $numeric_string), // array with heredocs
56 // associative arrays
57 /*9*/ array(1 => "one", 2 => "two", 3 => "three"), // explicit numeric keys, string values
58 array("one" => 1, "two" => 2, "three" => 3 ), // string keys & numeric values
59 array( 1 => 10, 2 => 20, 4 => 40, 3 => 30), // explicit numeric keys and numeric values
60 array( "one" => "ten", "two" => "twenty", "three" => "thirty"), // string key/value
61 array("one" => 1, 2 => "two", 4 => "four"), //mixed
63 // associative array, containing null/empty/boolean values as key/value
64 /*14*/ array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
65 array(true => "true", false => "false", "false" => false, "true" => true),
66 array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
67 array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
68 array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),
70 // array with repetative keys
71 /*19*/ array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
75 // array to be passsed to $arr2 argument
76 $arr2 = array (
77 1, 1.1, "hello", "one", NULL, 2,
78 'world', true, false, false => 5, 'aaaa\r', "aaaa\r",
79 $numeric_string, $diff_whitespaces,
80 "one" => "ten", 4 => "four", "two" => 2, 2 => "two",
81 '', null => "null", '' => 'emptys'
84 // loop through each sub-array within $arrrays to check the behavior of array_intersect()
85 $iterator = 1;
86 foreach($arrays as $arr1) {
87 echo "-- Iterator $iterator --\n";
89 // Calling array_intersect() with default arguments
90 var_dump( array_intersect($arr1, $arr2) );
92 // Calling array_intersect() with more arguments.
93 // additional argument passed is the same as $arr1 argument
94 var_dump( array_intersect($arr1, $arr2, $arr1) );
95 $iterator++;
98 echo "Done";