3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array('a','b'); $t = &$array; foreach($t as $value) if ($value == 'a') $t = array_merge($t, array('c')); else echo($value); var_dump($array);

Abusive script

This script was stopped while abusing our resources

Output for 5.3.21 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Output for 7.0.9 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.11
barray(3) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" }

preferences:
25.67 ms | 1140 KiB | 9 Q