3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = ['foo'=>1, 'bar'=>2]; $last = $current = memory_get_usage(); foreach($array as $k=>&$v) { $last = $current; $current = memory_get_usage(); echo "Diff is " . ($current - $last) . "\n"; $array['baz']=3; $last = $current; $current = memory_get_usage(); echo "Diff is " . ($current - $last) . "\n"; echo $v . "\n"; }
Output for 7.1.0
Diff is 424 Diff is 32 1 Diff is 24 Diff is 0 2 Diff is 24 Diff is 0 3
Output for 7.0.0 - 7.0.14
Diff is 48 Diff is 32 1 Diff is 24 Diff is 0 2 Diff is 24 Diff is 0 3
Output for 5.6.0 - 5.6.28
Diff is 448 Diff is 184 1 Diff is 0 Diff is 0 2 Diff is 0 Diff is 0 3
Output for 5.4.0 - 5.5.38
Diff is 480 Diff is 168 1 Diff is 0 Diff is 0 2 Diff is 0 Diff is 0 3
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/B2W2t on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/B2W2t on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/B2W2t on line 3
Process exited with code 255.