1--TEST--
2Test array_merge_recursive() function : usage variations - common key and value(Bug#43559)
3--FILE--
4<?php
5/*
6 * Testing the functionality of array_merge_recursive() by passing
7 * arrays having common key and value.
8*/
9
10echo "*** Testing array_merge_recursive() : arrays with common key and value ***\n";
11
12/* initialize the array having duplicate values */
13
14// integer values
15$arr1 = array("a" => 1, "b" => 2);
16$arr2 = array("b" => 2, "c" => 4);
17echo "-- Integer values --\n";
18var_dump( array_merge_recursive($arr1, $arr2) );
19
20// float values
21$arr1 = array("a" => 1.1, "b" => 2.2);
22$arr2 = array("b" => 2.2, "c" => 3.3);
23echo "-- Float values --\n";
24var_dump( array_merge_recursive($arr1, $arr2) );
25
26// string values
27$arr1 = array("a" => "hello", "b" => "world");
28$arr2 = array("b" => "world", "c" => "string");
29echo "-- String values --\n";
30var_dump( array_merge_recursive($arr1, $arr2) );
31
32// boolean values
33$arr1 = array("a" => true, "b" => false);
34$arr2 = array("b" => false);
35echo "-- Boolean values --\n";
36var_dump( array_merge_recursive($arr1, $arr2) );
37
38// null values
39$arr1 = array( "a" => NULL);
40$arr2 = array( "a" => NULL);
41echo "-- Null values --\n";
42var_dump( array_merge_recursive($arr1, $arr2) );
43
44echo "Done";
45?>
46--EXPECT--
47*** Testing array_merge_recursive() : arrays with common key and value ***
48-- Integer values --
49array(3) {
50  ["a"]=>
51  int(1)
52  ["b"]=>
53  array(2) {
54    [0]=>
55    int(2)
56    [1]=>
57    int(2)
58  }
59  ["c"]=>
60  int(4)
61}
62-- Float values --
63array(3) {
64  ["a"]=>
65  float(1.1)
66  ["b"]=>
67  array(2) {
68    [0]=>
69    float(2.2)
70    [1]=>
71    float(2.2)
72  }
73  ["c"]=>
74  float(3.3)
75}
76-- String values --
77array(3) {
78  ["a"]=>
79  string(5) "hello"
80  ["b"]=>
81  array(2) {
82    [0]=>
83    string(5) "world"
84    [1]=>
85    string(5) "world"
86  }
87  ["c"]=>
88  string(6) "string"
89}
90-- Boolean values --
91array(2) {
92  ["a"]=>
93  bool(true)
94  ["b"]=>
95  array(2) {
96    [0]=>
97    bool(false)
98    [1]=>
99    bool(false)
100  }
101}
102-- Null values --
103array(1) {
104  ["a"]=>
105  array(2) {
106    [0]=>
107    NULL
108    [1]=>
109    NULL
110  }
111}
112Done
113