2 Test array_intersect_assoc() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments
5 /* Prototype : array array_intersect_assoc(array $arr1, array $arr2 [, array $...])
6 * Description: Returns the entries of arr1 that have values which are present in all the other arguments.
7 * Keys are used to do more restrictive check
8 * Source code: ext/standard/array.c
12 * Testing the behavior of array_intersect_assoc() by passing 2-D arrays
13 * to both $arr1 and $arr2 argument.
14 * Optional argument takes the same value as that of $arr1
17 echo "*** Testing array_intersect_assoc() : passing two dimensional array to both \$arr1 and \$arr2 arguments ***\n";
19 // two dimensional arrays for $arr1 and $arr2 argument
22 // arrays with default keys
23 array(1, 2, "hello", 'world'),
26 // arrays with explicit keys
27 array(1 => "one", 2 => "two", 3 => "three"),
28 array("ten" => 10, "twenty" => 20.00, "thirty" => 30)
33 array(1 => "one", 2 => "two", 3 => "three")
36 /* Passing the entire array as argument to $arr1 and $arr2 */
37 // Calling array_intersect_assoc() with default arguments
38 echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n";
39 echo "- With default arguments -\n";
40 var_dump( array_intersect_assoc($arr1, $arr2) );
42 // Calling array_intersect_assoc() with more arguments
43 // additional argument passed is the same as $arr1
44 echo "- With more arguments -\n";
45 var_dump( array_intersect_assoc($arr1, $arr2, $arr1) );
47 /* Passing the sub-array as argument to $arr1 and $arr2 */
48 // Calling array_intersect_assoc() with default arguments
49 echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n";
50 echo "- With default arguments -\n";
51 var_dump( array_intersect_assoc($arr1[0], $arr2[0]) );
53 // Calling array_intersect_assoc() with more arguments
54 // additional argument passed is the same as $arr1
55 echo "- With more arguments -\n";
56 var_dump( array_intersect_assoc($arr1[0], $arr2[0], $arr1[0]) );
61 *** Testing array_intersect_assoc() : passing two dimensional array to both $arr1 and $arr2 arguments ***
62 -- Passing the entire 2-D array to $arr1 and $arr2 --
63 - With default arguments -
65 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
67 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
69 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
71 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
96 - With more arguments -
98 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
100 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
102 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
104 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
106 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
108 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
110 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
112 Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
137 -- Passing the sub-array to $arr1 and $arr2 --
138 - With default arguments -
145 - With more arguments -