1--TEST-- 2Test 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 15echo "*** 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 35echo "-- With default argument --\n"; 36var_dump( array_merge_recursive($arr1) ); 37 38echo "-- With more arguments --\n"; 39var_dump( array_merge_recursive($arr1, $arr2) ); 40 41echo "Done"; 42?> 43--EXPECT-- 44*** Testing array_merge_recursive() : array with reference variables for $arr1 argument *** 45-- With default argument -- 46array(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 -- 61array(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} 82Done 83