3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [0 => 'foobar', 1 => 'some_condition']; foreach ($arr as $k=>$v) { if ('some_condition' == $v) { unset($arr[$k]); } } var_dump($arr);
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.32, 8.0.0 - 8.0.24, 8.1.0 - 8.1.11
array(1) { [0]=> string(6) "foobar" }

preferences:
66.48 ms | 411 KiB | 5 Q