quick links

Find min value in array

There are three way to find min value in array

Using max function

<?php
$array = array(44,16,81,12);
echo(min($array));
?>

OUTPUT: 12

Using foreach loop

<?php
$array = array(44,16,81,12);
foreach($array as $value) {
if($value < $b) {
$b = $value;
}
}
echo $b;
?>

OUTPUT: 12

Using for loop

<?php
$array = array(44,16,81,12);
$b = 0;
for($i=0;$i<count($array); $i++) {
if($array[$i] < $b) {
$b = $array[$i];
}
}
echo $b;
?>

OUTPUT: 12

 

About Us

Joomla Web Solution

We love working with PHP, HTML5, CSS3, jQuery and the most-loved content management framework in the world, Joomla!

LIKE US ON FACEBOOK