xref: /PHP-7.1/ext/standard/tests/array/bug48854.phpt (revision fb235dc0)
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--EXPECTF--
26array(2) {
27  [%u|b%"friends"]=>
28  int(5)
29  [%u|b%"children"]=>
30  array(1) {
31    [%u|b%"dogs"]=>
32    int(0)
33  }
34}
35array(2) {
36  [%u|b%"friends"]=>
37  int(10)
38  [%u|b%"children"]=>
39  array(1) {
40    [%u|b%"cats"]=>
41    int(5)
42  }
43}
44