How to get highest value from multidimensional array using PHP

Many times we need to find the max/min value of a particular key from an multidimensional array Below are the function through which we can get these values. Please check example right below it.

Example

$arr= array(array(110, 20, 52),array(105, 56, 89, 96),array( 556, 89, 96));
$b = 0;
foreach ($arr as $val)
{
	foreach($val as $key=>$val1)
	{
		if ($val1 > $b)
	 	{
        $b = $val1;
    	}
	}   	
}
echo $b;
?>

Leave a Reply

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