3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [ 'Foo', 'Bar', 'Baz' ]; foreach ($array as $i => $item) { if ($item === 'Baz') { $array[$i] = 'Bazoo!'; } } var_dump($array);
based on snBjk
Output for 5.5.0 - 7.3.0beta1
array(3) { [0]=> string(3) "Foo" [1]=> string(3) "Bar" [2]=> string(6) "Bazoo!" }