3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); function test_alter(&$item1, $key, $prefix) { $item1 = "$item1 : $prefix"; } function test_print($item2, $key) { echo "$key. $item2\n"; } echo "Before ...:\n"; array_walk($fruits, 'test_print'); // array_walk($fruits, 'test_alter', 'fruit'); echo "... and after:\n"; array_walk(&fruits,'test_alter','fruit'); array_walk($fruits, 'test_print'); ?>
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected '&' in /in/BcGrj on line 19
Process exited with code 255.
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17
Parse error: syntax error, unexpected ',', expecting '(' in /in/BcGrj on line 19
Process exited with code 255.

preferences:
156.58 ms | 1395 KiB | 28 Q