1--TEST--
2Test array_merge_recursive() function : basic functionality - associative arrays
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
10echo "*** Testing array_merge_recursive() : associative arrays ***\n";
11
12// Initialise the arrays
13$arr1 = array(1 => "one", 2 => array(1, 2));
14$arr2 = array(2 => 'three', "four" => array("hello", 'world'));
15$arr3 = array(1 => array(6, 7), 'four' => array("str1", 'str2'));
16
17// Calling array_merge_recursive() with default arguments
18echo "-- With default argument --\n";
19var_dump( array_merge_recursive($arr1) );
20
21// Calling array_merge_recursive() with more arguments
22echo "-- With more arguments --\n";
23var_dump( array_merge_recursive($arr1,$arr2) );
24var_dump( array_merge_recursive($arr1,$arr2,$arr3) );
25
26echo "Done";
27?>
28--EXPECT--
29*** Testing array_merge_recursive() : associative arrays ***
30-- With default argument --
31array(2) {
32  [0]=>
33  string(3) "one"
34  [1]=>
35  array(2) {
36    [0]=>
37    int(1)
38    [1]=>
39    int(2)
40  }
41}
42-- With more arguments --
43array(4) {
44  [0]=>
45  string(3) "one"
46  [1]=>
47  array(2) {
48    [0]=>
49    int(1)
50    [1]=>
51    int(2)
52  }
53  [2]=>
54  string(5) "three"
55  ["four"]=>
56  array(2) {
57    [0]=>
58    string(5) "hello"
59    [1]=>
60    string(5) "world"
61  }
62}
63array(5) {
64  [0]=>
65  string(3) "one"
66  [1]=>
67  array(2) {
68    [0]=>
69    int(1)
70    [1]=>
71    int(2)
72  }
73  [2]=>
74  string(5) "three"
75  ["four"]=>
76  array(4) {
77    [0]=>
78    string(5) "hello"
79    [1]=>
80    string(5) "world"
81    [2]=>
82    string(4) "str1"
83    [3]=>
84    string(4) "str2"
85  }
86  [3]=>
87  array(2) {
88    [0]=>
89    int(6)
90    [1]=>
91    int(7)
92  }
93}
94Done
95