1--TEST--
2Test array_merge_recursive() function : usage variations - array with reference variables
3--FILE--
4<?php
5/*
6 * Testing the functionality of array_merge_recursive() by passing
7 * array having reference variables.
8*/
9
10echo "*** Testing array_merge_recursive() : array with reference variables for \$arr1 argument ***\n";
11
12$value1 = 10;
13$value2 = "hello";
14$value3 = 0;
15$value4 = &$value2;
16
17// input array containing elements as reference variables
18$arr1 = array(
19  0 => 0,
20  1 => &$value4,
21  2 => &$value2,
22  3 => "hello",
23  4 => &$value3,
24  $value4 => &$value2
25);
26
27// initialize the second argument
28$arr2 = array($value4 => "hello", &$value2);
29
30echo "-- With default argument --\n";
31var_dump( array_merge_recursive($arr1) );
32
33echo "-- With more arguments --\n";
34var_dump( array_merge_recursive($arr1, $arr2) );
35
36echo "Done";
37?>
38--EXPECT--
39*** Testing array_merge_recursive() : array with reference variables for $arr1 argument ***
40-- With default argument --
41array(6) {
42  [0]=>
43  int(0)
44  [1]=>
45  &string(5) "hello"
46  [2]=>
47  &string(5) "hello"
48  [3]=>
49  string(5) "hello"
50  [4]=>
51  &int(0)
52  ["hello"]=>
53  &string(5) "hello"
54}
55-- With more arguments --
56array(7) {
57  [0]=>
58  int(0)
59  [1]=>
60  &string(5) "hello"
61  [2]=>
62  &string(5) "hello"
63  [3]=>
64  string(5) "hello"
65  [4]=>
66  &int(0)
67  ["hello"]=>
68  array(2) {
69    [0]=>
70    string(5) "hello"
71    [1]=>
72    string(5) "hello"
73  }
74  [5]=>
75  &string(5) "hello"
76}
77Done
78