Annotation of embedaddon/php/ext/standard/tests/array/array_merge_recursive_basic1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_merge_recursive() function : basic functionality - array with default keys
3: --FILE--
4: <?php
5: /* Prototype : array array_merge_recursive(array $arr1[, array $...])
6: * Description: Recursively merges elements from passed arrays into one array
7: * Source code: ext/standard/array.c
8: */
9:
10: echo "*** Testing array_merge_recursive() : array with default keys ***\n";
11:
12: // Initialise the arrays
13: $arr1 = array(1, array(1, 2));
14: $arr2 = array(3, array("hello", 'world'));
15: $arr3 = array(array(6, 7), array("str1", 'str2'));
16:
17: // Calling array_merge_recursive() with default arguments
18: echo "-- With default argument --\n";
19: var_dump( array_merge_recursive($arr1) );
20:
21: // Calling array_merge_recursive() with more arguments
22: echo "-- With more arguments --\n";
23: var_dump( array_merge_recursive($arr1,$arr2) );
24: var_dump( array_merge_recursive($arr1,$arr2,$arr3) );
25:
26: echo "Done";
27: ?>
28: --EXPECTF--
29: *** Testing array_merge_recursive() : array with default keys ***
30: -- With default argument --
31: array(2) {
32: [0]=>
33: int(1)
34: [1]=>
35: array(2) {
36: [0]=>
37: int(1)
38: [1]=>
39: int(2)
40: }
41: }
42: -- With more arguments --
43: array(4) {
44: [0]=>
45: int(1)
46: [1]=>
47: array(2) {
48: [0]=>
49: int(1)
50: [1]=>
51: int(2)
52: }
53: [2]=>
54: int(3)
55: [3]=>
56: array(2) {
57: [0]=>
58: string(5) "hello"
59: [1]=>
60: string(5) "world"
61: }
62: }
63: array(6) {
64: [0]=>
65: int(1)
66: [1]=>
67: array(2) {
68: [0]=>
69: int(1)
70: [1]=>
71: int(2)
72: }
73: [2]=>
74: int(3)
75: [3]=>
76: array(2) {
77: [0]=>
78: string(5) "hello"
79: [1]=>
80: string(5) "world"
81: }
82: [4]=>
83: array(2) {
84: [0]=>
85: int(6)
86: [1]=>
87: int(7)
88: }
89: [5]=>
90: array(2) {
91: [0]=>
92: string(4) "str1"
93: [1]=>
94: string(4) "str2"
95: }
96: }
97: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>