Skip to content

Instantly share code, notes, and snippets.

@fokosun
Created September 11, 2023 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fokosun/3f150bd852853a05a18dab18067f3ac5 to your computer and use it in GitHub Desktop.
Save fokosun/3f150bd852853a05a18dab18067f3ac5 to your computer and use it in GitHub Desktop.
<?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