3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $max = 1000; $arr = array_fill(0, $max, 1); $mem = memory_get_usage(); $count = 0; foreach ($arr as $key => &$val) { $count ++; $arr[$max+1] = 9999; } echo $count.' === '.(memory_get_usage()-$mem);
Output for 7.0.0 - 7.1.0
1001 === 24088
Output for 5.5.24 - 5.6.28
1001 === 48648
Output for 5.4.0 - 5.4.45
1001 === 48656
Output for 5.3.0 - 5.3.29
1001 === 48672
Output for 5.2.10 - 5.2.17
1001 === 40648
Output for 5.2.2 - 5.2.9
1001 === 40712
Output for 5.2.1
1000 === 32408
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/vuNG5 on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/vuNG5 on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/vuNG5 on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/vuNG5 on line 7
Process exited with code 255.