3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $objects = array( new StdClass, new StdClass ); foreach ($objects as $obj) { $obj->var = true; } var_dump($objects); $arrays = array( array(), array() ); foreach ($arrays as $arr) { $arr['var'] = true; } var_dump($arrays);
Output for 5.0.0 - 5.6.21, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> object(stdClass)#1 (1) { ["var"]=> bool(true) } [1]=> object(stdClass)#2 (1) { ["var"]=> bool(true) } } array(2) { [0]=> array(0) { } [1]=> array(0) { } }
Output for 4.3.0 - 4.4.9
array(2) { [0]=> object(stdClass)(0) { } [1]=> object(stdClass)(0) { } } array(2) { [0]=> array(0) { } [1]=> array(0) { } }