How to find the minimum value of an array using PHP

First create an array with some numeric value. Now create a temporary variable $temp in which stored array’s first index’s value i.e 100 and follow below example.

Example

$arr=array(100,11,12,0,13,10,15);
$temp=$arr[0];
foreach($arr as $x)
{
	if($x<$temp)
	{
		$temp=$x;
	}
}
echo "Minimum value of array = ".$temp;
?>

Leave a Reply

Your email address will not be published. Required fields are marked *