/*
* How to get min number from a array
* */
$numbers = array(9, 0, 1, 77, 4, 5, -1, 10);
$min_number = $numbers[0];
$length = count($numbers);//in order to save time we initial length outside of the loops
for($i = 0; $i < $length; $i++){
if ($min_number > $numbers[$i]){
$min_number = $numbers[$i];
}
}
echo "Min number is the array is ", $min_number;
* How to get min number from a array
* */
$numbers = array(9, 0, 1, 77, 4, 5, -1, 10);
$min_number = $numbers[0];
$length = count($numbers);//in order to save time we initial length outside of the loops
for($i = 0; $i < $length; $i++){
if ($min_number > $numbers[$i]){
$min_number = $numbers[$i];
}
}
echo "Min number is the array is ", $min_number;
No comments:
Post a Comment