Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_assoc_variation9.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test array_intersect_assoc() function : usage variations - two dimensional arrays for $arr1 and $arr2 arguments
3: --FILE--
4: <?php
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
9: */
10:
11: /*
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
15: */
16:
17: echo "*** Testing array_intersect_assoc() : passing two dimensional array to both \$arr1 and \$arr2 arguments ***\n";
18:
19: // two dimensional arrays for $arr1 and $arr2 argument
20: $arr1 = array (
21:
22: // arrays with default keys
23: array(1, 2, "hello", 'world'),
24: array(1, 2, 3, 4),
25:
26: // arrays with explicit keys
27: array(1 => "one", 2 => "two", 3 => "three"),
28: array("ten" => 10, "twenty" => 20.00, "thirty" => 30)
29: );
30:
31: $arr2 = array (
32: array(1, 2, 3, 4),
33: array(1 => "one", 2 => "two", 3 => "three")
34: );
35:
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) );
41:
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) );
46:
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]) );
52:
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]) );
57:
58: echo "Done";
59: ?>
60: --EXPECTF--
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 -
1.1.1.2 ! misho 64:
! 65: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 66:
! 67: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 68:
! 69: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 70:
! 71: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
1.1 misho 72: array(2) {
73: [0]=>
74: array(4) {
75: [0]=>
76: int(1)
77: [1]=>
78: int(2)
79: [2]=>
80: string(5) "hello"
81: [3]=>
82: string(5) "world"
83: }
84: [1]=>
85: array(4) {
86: [0]=>
87: int(1)
88: [1]=>
89: int(2)
90: [2]=>
91: int(3)
92: [3]=>
93: int(4)
94: }
95: }
96: - With more arguments -
1.1.1.2 ! misho 97:
! 98: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 99:
! 100: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 101:
! 102: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 103:
! 104: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 105:
! 106: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 107:
! 108: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 109:
! 110: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
! 111:
! 112: Notice: Array to string conversion in %sarray_intersect_assoc_variation9.php on line %d
1.1 misho 113: array(2) {
114: [0]=>
115: array(4) {
116: [0]=>
117: int(1)
118: [1]=>
119: int(2)
120: [2]=>
121: string(5) "hello"
122: [3]=>
123: string(5) "world"
124: }
125: [1]=>
126: array(4) {
127: [0]=>
128: int(1)
129: [1]=>
130: int(2)
131: [2]=>
132: int(3)
133: [3]=>
134: int(4)
135: }
136: }
137: -- Passing the sub-array to $arr1 and $arr2 --
138: - With default arguments -
139: array(2) {
140: [0]=>
141: int(1)
142: [1]=>
143: int(2)
144: }
145: - With more arguments -
146: array(2) {
147: [0]=>
148: int(1)
149: [1]=>
150: int(2)
151: }
152: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>