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