3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = (object) array(); foreach (array(1,2,3) as $a->foo[] => $a->bar[]) { print_r($a); }
Output for 5.1.0 - 7.1.0
stdClass Object ( [bar] => Array ( [0] => 1 ) [foo] => Array ( [0] => 0 ) ) stdClass Object ( [bar] => Array ( [0] => 1 [1] => 2 ) [foo] => Array ( [0] => 0 [1] => 1 ) ) stdClass Object ( [bar] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [foo] => Array ( [0] => 0 [1] => 1 [2] => 2 ) )
Output for 4.3.0 - 5.0.5
stdClass Object ( [foo] => Array ( [0] => 0 ) [bar] => Array ( [0] => 1 ) ) stdClass Object ( [foo] => Array ( [0] => 0 [1] => 1 ) [bar] => Array ( [0] => 1 [1] => 2 ) ) stdClass Object ( [foo] => Array ( [0] => 0 [1] => 1 [2] => 2 ) [bar] => Array ( [0] => 1 [1] => 2 [2] => 3 ) )