1--TEST-- 2Test array_map() function : usage variations - arrays of different size 3--FILE-- 4<?php 5/* 6 * Test array_map() by passing array having different size 7 * 1) first array as empty array 8 * 2) second array as empty array 9 * 3) second array shorter than first array 10 * 4) first array shorter than second array 11 * 5) one more array than callback function arguments 12 */ 13 14echo "*** Testing array_map() : arrays with diff. size ***\n"; 15 16function callback($a, $b) 17{ 18 return array($a => $b); 19} 20 21// calling array_map with different arrays 22var_dump( array_map('callback', array(1, 2, 3), array()) ); 23var_dump( array_map('callback', array(), array('a', 'b', 'c')) ); 24var_dump( array_map('callback', array(1, 2, 3), array('a', 'b')) ); 25var_dump( array_map('callback', array(012, 0x2F, 0X1A), array(2.3, 12.4e2)) ); 26var_dump( array_map('callback', array(), array(1, 2, 3), array('a', 'b')) ); // passing more no. of arrays than callback function argument 27 28echo "Done"; 29?> 30--EXPECT-- 31*** Testing array_map() : arrays with diff. size *** 32array(3) { 33 [0]=> 34 array(1) { 35 [1]=> 36 NULL 37 } 38 [1]=> 39 array(1) { 40 [2]=> 41 NULL 42 } 43 [2]=> 44 array(1) { 45 [3]=> 46 NULL 47 } 48} 49array(3) { 50 [0]=> 51 array(1) { 52 [""]=> 53 string(1) "a" 54 } 55 [1]=> 56 array(1) { 57 [""]=> 58 string(1) "b" 59 } 60 [2]=> 61 array(1) { 62 [""]=> 63 string(1) "c" 64 } 65} 66array(3) { 67 [0]=> 68 array(1) { 69 [1]=> 70 string(1) "a" 71 } 72 [1]=> 73 array(1) { 74 [2]=> 75 string(1) "b" 76 } 77 [2]=> 78 array(1) { 79 [3]=> 80 NULL 81 } 82} 83array(3) { 84 [0]=> 85 array(1) { 86 [10]=> 87 float(2.3) 88 } 89 [1]=> 90 array(1) { 91 [47]=> 92 float(1240) 93 } 94 [2]=> 95 array(1) { 96 [26]=> 97 NULL 98 } 99} 100array(3) { 101 [0]=> 102 array(1) { 103 [""]=> 104 int(1) 105 } 106 [1]=> 107 array(1) { 108 [""]=> 109 int(2) 110 } 111 [2]=> 112 array(1) { 113 [""]=> 114 int(3) 115 } 116} 117Done 118