2 /* Prototype : array array_intersect_assoc(array $arr1, array $arr2 [, array $...])
3 * Description: Returns the entries of arr1 that have values which are present in all the other arguments.
4 * Keys are used to do more restrictive check
5 * Source code: ext/standard/array.c
9 * Testing the behavior of array_intersect_assoc() by passing 2-D arrays
10 * to both $arr1 and $arr2 argument.
11 * Optional argument takes the same value as that of $arr1
14 echo "*** Testing array_intersect_assoc() : passing two dimensional array to both \$arr1 and \$arr2 arguments ***\n";
16 // two dimensional arrays for $arr1 and $arr2 argument
19 // arrays with default keys
20 array(1, 2, "hello", 'world'),
23 // arrays with explicit keys
24 array(1 => "one", 2 => "two", 3 => "three"),
25 array("ten" => 10, "twenty" => 20.00, "thirty" => 30)
30 array(1 => "one", 2 => "two", 3 => "three")
33 /* Passing the entire array as argument to $arr1 and $arr2 */
34 // Calling array_intersect_assoc() with default arguments
35 echo "-- Passing the entire 2-D array to \$arr1 and \$arr2 --\n";
36 echo "- With default arguments -\n";
37 var_dump( array_intersect_assoc($arr1, $arr2) );
39 // Calling array_intersect_assoc() with more arguments
40 // additional argument passed is the same as $arr1
41 echo "- With more arguments -\n";
42 var_dump( array_intersect_assoc($arr1, $arr2, $arr1) );
44 /* Passing the sub-array as argument to $arr1 and $arr2 */
45 // Calling array_intersect_assoc() with default arguments
46 echo "-- Passing the sub-array to \$arr1 and \$arr2 --\n";
47 echo "- With default arguments -\n";
48 var_dump( array_intersect_assoc($arr1[0], $arr2[0]) );
50 // Calling array_intersect_assoc() with more arguments
51 // additional argument passed is the same as $arr1
52 echo "- With more arguments -\n";
53 var_dump( array_intersect_assoc($arr1[0], $arr2[0], $arr1[0]) );