1--TEST-- 2Test array_merge() function : usage variations - multi-dimensional arrays 3--FILE-- 4<?php 5/* Prototype : array array_merge(array $arr1, array $arr2 [, array $...]) 6 * Description: Merges elements from passed arrays into one array 7 * Source code: ext/standard/array.c 8 */ 9 10/* 11 * Test array_merge() with multi-dimensional arrays 12 */ 13 14echo "*** Testing array_merge() : usage variations ***\n"; 15 16$arr1 = array('zero', 'one', 'two', array(0)); 17$arr2 = array(1, 2, 3); 18 19echo "\n-- Merge a two-dimensional and a one-dimensional array --\n"; 20var_dump(array_merge($arr1, $arr2)); 21 22echo "\n-- Merge an array and a sub-array --\n"; 23var_dump(array_merge($arr1[3], $arr2)); 24var_dump(array_merge($arr2, $arr1[3])); 25 26echo "Done"; 27?> 28 29--EXPECTF-- 30*** Testing array_merge() : usage variations *** 31 32-- Merge a two-dimensional and a one-dimensional array -- 33array(7) { 34 [0]=> 35 string(4) "zero" 36 [1]=> 37 string(3) "one" 38 [2]=> 39 string(3) "two" 40 [3]=> 41 array(1) { 42 [0]=> 43 int(0) 44 } 45 [4]=> 46 int(1) 47 [5]=> 48 int(2) 49 [6]=> 50 int(3) 51} 52 53-- Merge an array and a sub-array -- 54array(4) { 55 [0]=> 56 int(0) 57 [1]=> 58 int(1) 59 [2]=> 60 int(2) 61 [3]=> 62 int(3) 63} 64array(4) { 65 [0]=> 66 int(1) 67 [1]=> 68 int(2) 69 [2]=> 70 int(3) 71 [3]=> 72 int(0) 73} 74Done