1--TEST-- 2Test array_map() function : usage variations - array having subarrays 3--FILE-- 4<?php 5/* Prototype : array array_map ( callback $callback , array $arr1 [, array $... ] ) 6 * Description: Applies the callback to the elements of the given arrays 7 * Source code: ext/standard/array.c 8 */ 9 10/* 11 * Test array_map() by passing array having different subarrays 12 */ 13 14echo "*** Testing array_map() : array having subarrays ***\n"; 15 16function callback($a) 17{ 18 return $a; 19} 20 21// different subarrays 22$arr1 = array( 23 array(), 24 array(1, 2), 25 array('a', 'b'), 26 array(1, 2, 'a', 'b'), 27 array(1 => 'a', 'b' => 2) 28); 29 30var_dump( array_map('callback', $arr1)); 31echo "Done"; 32?> 33--EXPECT-- 34*** Testing array_map() : array having subarrays *** 35array(5) { 36 [0]=> 37 array(0) { 38 } 39 [1]=> 40 array(2) { 41 [0]=> 42 int(1) 43 [1]=> 44 int(2) 45 } 46 [2]=> 47 array(2) { 48 [0]=> 49 string(1) "a" 50 [1]=> 51 string(1) "b" 52 } 53 [3]=> 54 array(4) { 55 [0]=> 56 int(1) 57 [1]=> 58 int(2) 59 [2]=> 60 string(1) "a" 61 [3]=> 62 string(1) "b" 63 } 64 [4]=> 65 array(2) { 66 [1]=> 67 string(1) "a" 68 ["b"]=> 69 int(2) 70 } 71} 72Done 73