xref: /PHP-7.4/ext/standard/tests/array/bug48854.phpt (revision ded3d984)
1--TEST--
2Bug #48854 (array_merge_recursive modifies arrays after first one)
3--FILE--
4<?php
5
6$array1 = array(
7       'friends' => 5,
8       'children' => array(
9               'dogs' => 0,
10       ),
11);
12
13$array2 = array(
14       'friends' => 10,
15       'children' => array(
16               'cats' => 5,
17       ),
18);
19
20$merged = array_merge_recursive($array1, $array2);
21
22var_dump($array1, $array2);
23
24?>
25--EXPECT--
26array(2) {
27  ["friends"]=>
28  int(5)
29  ["children"]=>
30  array(1) {
31    ["dogs"]=>
32    int(0)
33  }
34}
35array(2) {
36  ["friends"]=>
37  int(10)
38  ["children"]=>
39  array(1) {
40    ["cats"]=>
41    int(5)
42  }
43}
44