Created
September 11, 2023 15:34
-
-
Save fokosun/3f150bd852853a05a18dab18067f3ac5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nums = [10, 5, 253, 54, 4]; | |
$max = $nums[0]; | |
$min = $nums[0]; | |
$count = count($nums) - 1; | |
foreach(range(0, $count) as $i) { | |
if ($nums[$i] > $max) { | |
$max = $nums[$i]; | |
} | |
if ($nums[$i] <= $min) { | |
$min = $nums[$i]; | |
} | |
} | |
echo "Min is: " . $min . PHP_EOL; | |
echo "Max is: " . $max; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment