3v4l.org

run code in 500+ PHP versions simultaneously
<?php $scores = [45, '23', 1]; $scores_string = ''; $len = count($scores); for ($i = 0; $i < $len; $i++) { if (empty($scores[$i]) || !is_numeric($scores[$i])) { $scores_string = 'You must enter three valid numbers for scores.'; break; } } if ($scores_string != '') { echo $scores_string; // do anything else you need } else { // all is OK! }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7

preferences:
529.39 ms | 1240 KiB | 4 Q