1--TEST-- 2Test array_map() function : usage variations - references 3--FILE-- 4<?php 5 6echo "*** Testing array_map() : references ***\n"; 7$arr = array("k1" => "v1","k2"=>"v2"); 8$arr[]=&$arr["k1"]; 9$arr[]=&$arr; 10function cb1 ($a) {var_dump ($a);return array ($a);}; 11var_dump( array_map("cb1", $arr)); 12var_dump( array_map(null, $arr)); 13var_dump( array_map(null, $arr, $arr)); 14 15// break cycles 16$arr[0] = null; 17$arr[1] = null; 18 19echo "Done"; 20?> 21--EXPECT-- 22*** Testing array_map() : references *** 23string(2) "v1" 24string(2) "v2" 25string(2) "v1" 26array(4) { 27 ["k1"]=> 28 &string(2) "v1" 29 ["k2"]=> 30 string(2) "v2" 31 [0]=> 32 &string(2) "v1" 33 [1]=> 34 *RECURSION* 35} 36array(4) { 37 ["k1"]=> 38 array(1) { 39 [0]=> 40 string(2) "v1" 41 } 42 ["k2"]=> 43 array(1) { 44 [0]=> 45 string(2) "v2" 46 } 47 [0]=> 48 array(1) { 49 [0]=> 50 string(2) "v1" 51 } 52 [1]=> 53 array(1) { 54 [0]=> 55 array(4) { 56 ["k1"]=> 57 &string(2) "v1" 58 ["k2"]=> 59 string(2) "v2" 60 [0]=> 61 &string(2) "v1" 62 [1]=> 63 *RECURSION* 64 } 65 } 66} 67array(4) { 68 ["k1"]=> 69 &string(2) "v1" 70 ["k2"]=> 71 string(2) "v2" 72 [0]=> 73 &string(2) "v1" 74 [1]=> 75 *RECURSION* 76} 77array(4) { 78 [0]=> 79 array(2) { 80 [0]=> 81 &string(2) "v1" 82 [1]=> 83 &string(2) "v1" 84 } 85 [1]=> 86 array(2) { 87 [0]=> 88 string(2) "v2" 89 [1]=> 90 string(2) "v2" 91 } 92 [2]=> 93 array(2) { 94 [0]=> 95 &string(2) "v1" 96 [1]=> 97 &string(2) "v1" 98 } 99 [3]=> 100 array(2) { 101 [0]=> 102 &array(4) { 103 ["k1"]=> 104 &string(2) "v1" 105 ["k2"]=> 106 string(2) "v2" 107 [0]=> 108 &string(2) "v1" 109 [1]=> 110 *RECURSION* 111 } 112 [1]=> 113 &array(4) { 114 ["k1"]=> 115 &string(2) "v1" 116 ["k2"]=> 117 string(2) "v2" 118 [0]=> 119 &string(2) "v1" 120 [1]=> 121 *RECURSION* 122 } 123 } 124} 125Done 126