3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array(1, 2, 3); function incrementArray($arr) { foreach($arr as $k => $el) { ++$arr[$k]; } } function incrementArrayRef(&$arr) { foreach($arr as $k => $el) { ++$arr[$k]; } } incrementArray($a); foreach($a as $b) { echo "" . $b . "\n"; } echo "\n"; incrementArrayRef($a); foreach($a as $b) { echo "" . $b . "\n"; }
based on Qsol5
Output for 4.3.0 - 7.2.0
1 2 3 2 3 4