Annotation of embedaddon/php/ext/standard/tests/array/array_merge_recursive_variation7.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_merge_recursive() function : usage variations - array with reference variables
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: * array having reference variables.
13: */
14:
15: echo "*** Testing array_merge_recursive() : array with reference variables for \$arr1 argument ***\n";
16:
17: $value1 = 10;
18: $value2 = "hello";
19: $value3 = 0;
20: $value4 = &$value2;
21:
22: // input array containing elements as reference variables
23: $arr1 = array(
24: 0 => 0,
25: 1 => &$value4,
26: 2 => &$value2,
27: 3 => "hello",
28: 4 => &$value3,
29: $value4 => &$value2
30: );
31:
32: // initialize the second argument
33: $arr2 = array($value4 => "hello", &$value2);
34:
35: echo "-- With default argument --\n";
36: var_dump( array_merge_recursive($arr1) );
37:
38: echo "-- With more arguments --\n";
39: var_dump( array_merge_recursive($arr1, $arr2) );
40:
41: echo "Done";
42: ?>
43: --EXPECTF--
44: *** Testing array_merge_recursive() : array with reference variables for $arr1 argument ***
45: -- With default argument --
46: array(6) {
47: [0]=>
48: int(0)
49: [1]=>
50: &string(5) "hello"
51: [2]=>
52: &string(5) "hello"
53: [3]=>
54: string(5) "hello"
55: [4]=>
56: &int(0)
57: ["hello"]=>
58: &string(5) "hello"
59: }
60: -- With more arguments --
61: array(7) {
62: [0]=>
63: int(0)
64: [1]=>
65: &string(5) "hello"
66: [2]=>
67: &string(5) "hello"
68: [3]=>
69: string(5) "hello"
70: [4]=>
71: &int(0)
72: ["hello"]=>
73: array(2) {
74: [0]=>
75: string(5) "hello"
76: [1]=>
77: string(5) "hello"
78: }
79: [5]=>
80: &string(5) "hello"
81: }
82: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>