1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
--TEST-- array_walk() function precerve foreach by reference iterator pointer --FILE-- <?php $a = [1,2,3,4,5]; foreach($a as &$v) { echo "$v\n"; if ($v == 3) { array_walk($a, function (&$x) {$x+=10;}); } } ?> --EXPECT-- 1 2 3 14 15