1--TEST-- 2Test array_map() function : basic functionality 3--FILE-- 4<?php 5echo "*** Testing array_map() : basic functionality ***\n"; 6 7function multiply($p, $q) { 8 return ($p * $q); 9} 10 11function square($p) { 12 return ($p * $p); 13} 14 15function concatenate($a, $b) { 16 return "$a = $b"; 17} 18 19// integer array 20$arr1 = array(1, 2, 3); 21$arr2 = array(4, 5, 6); 22 23echo "-- With two integer array --\n"; 24var_dump( array_map('multiply', $arr1, $arr2) ); 25 26echo "-- With single integer array --\n"; 27var_dump( array_map('square', $arr1) ); 28 29// string array 30$arr1 = array("one", "two"); 31$arr2 = array("single", "double"); 32 33echo "-- With string array --\n"; 34var_dump( array_map('concatenate', $arr1, $arr2) ); 35 36echo "Done"; 37?> 38--EXPECT-- 39*** Testing array_map() : basic functionality *** 40-- With two integer array -- 41array(3) { 42 [0]=> 43 int(4) 44 [1]=> 45 int(10) 46 [2]=> 47 int(18) 48} 49-- With single integer array -- 50array(3) { 51 [0]=> 52 int(1) 53 [1]=> 54 int(4) 55 [2]=> 56 int(9) 57} 58-- With string array -- 59array(2) { 60 [0]=> 61 string(12) "one = single" 62 [1]=> 63 string(12) "two = double" 64} 65Done 66