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 = "$prefix: $item1"; } function test_print($item2, $key) { echo "$key. $item2<br />\n"; } echo "Before ...:\n"; array_walk($fruits, 'test_print'); // array_walk($fruits, 'test_alter', 'fruit'); echo "... and after:\n"; array_walk($fruits,function(&$value, &$key){$key = $value; $value=false;}); var_dump($fruits);
Output for git.master, git.master_jit, rfc.property-hooks
Before ...: d. lemon<br /> a. orange<br /> b. banana<br /> c. apple<br /> ... and after: Warning: {closure}(): Argument #2 ($key) must be passed by reference, value given in /in/ER2rG on line 21 Warning: {closure}(): Argument #2 ($key) must be passed by reference, value given in /in/ER2rG on line 21 Warning: {closure}(): Argument #2 ($key) must be passed by reference, value given in /in/ER2rG on line 21 Warning: {closure}(): Argument #2 ($key) must be passed by reference, value given in /in/ER2rG on line 21 array(4) { ["d"]=> bool(false) ["a"]=> bool(false) ["b"]=> bool(false) ["c"]=> bool(false) }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
32.58 ms | 402 KiB | 8 Q