3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [0, 0, 4, 4, 5, 7]; for ($test = -1; $test < 9; ++$test) { echo "\ntest search for $test: "; $foundKey = 'not found'; foreach ($array as $key => $value) { if ($value >= $test) { $foundKey = $key; break; } } echo "index = $foundKey"; if (isset($array[$foundKey])) { echo ", value = {$array[$foundKey]}"; } }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
214.91 ms | 2079 KiB | 8 Q