1--TEST-- 2Test array_map() function : usage variations - array with references 3--FILE-- 4<?php 5/* 6 * Test array_map() by passing array having reference values for $arr1 argument 7 */ 8 9echo "*** Testing array_map() : array with references for 'arr1' argument ***\n"; 10 11function callback1($a) 12{ 13 return ($a); 14} 15 16function callback_cat($a, $b) 17{ 18 return ($a . $b); 19} 20 21// reference variables 22$value1 = 10; 23$value2 = "hello"; 24$value3 = 0; 25$value4 = &$value2; 26 27// array containing reference variables 28$arr1 = array( 29 0 => 0, 30 1 => &$value4, 31 2 => &$value2, 32 3 => "hello", 33 4 => &$value3, 34 $value4 => &$value2 35); 36echo "-- with one array --\n"; 37var_dump( array_map('callback1', $arr1) ); 38 39echo "-- with two arrays --\n"; 40var_dump( array_map('callback_cat', $arr1, $arr1) ); 41 42echo "Done"; 43?> 44--EXPECT-- 45*** Testing array_map() : array with references for 'arr1' argument *** 46-- with one array -- 47array(6) { 48 [0]=> 49 int(0) 50 [1]=> 51 string(5) "hello" 52 [2]=> 53 string(5) "hello" 54 [3]=> 55 string(5) "hello" 56 [4]=> 57 int(0) 58 ["hello"]=> 59 string(5) "hello" 60} 61-- with two arrays -- 62array(6) { 63 [0]=> 64 string(2) "00" 65 [1]=> 66 string(10) "hellohello" 67 [2]=> 68 string(10) "hellohello" 69 [3]=> 70 string(10) "hellohello" 71 [4]=> 72 string(2) "00" 73 [5]=> 74 string(10) "hellohello" 75} 76Done 77