3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function format(array &$collection) { foreach($collection as $k => $v) { $collection["prefix_{$k}"] = $v; } } $collection = array('a' => 1, 'b' => 2, 'c' => 3); var_dump($collection); format($collection); var_dump($collection);
Output for hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } array(6) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) ["prefix_a"]=> int(1) ["prefix_b"]=> int(2) ["prefix_c"]=> int(3) }
Output for 5.4.0 - 5.6.28
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 14606 bytes) in /in/7VqqQ on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.29
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 14506 bytes) in /in/7VqqQ on line 4
Process exited with code 255.
Output for 5.2.3 - 5.2.17
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 14626 bytes) in /in/7VqqQ on line 4
Process exited with code 255.
Output for 5.2.1 - 5.2.2
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) } Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 14619 bytes) in /in/7VqqQ on line 4
Process exited with code 255.
Output for 5.1.0 - 5.2.0
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> int(3) }
Process exited with code 137.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/7VqqQ on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/7VqqQ on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/7VqqQ on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/7VqqQ on line 2
Process exited with code 255.