如何查找数组的最小值


How to find the lowest value of an array?

print_r($data['SearchAvailResponse']['Hotel'])的结果:

Array
(
    [0] => Array
        (
            [HotelNo] => 1    
            [HCode] => IDJKT_00085
            [Name] => Cebu Grand Hotel       
            [Currency] => USD
            [TotalRate] => 56          
        )
    [1] => Array
        (
            [HotelNo] => 2          
            [HCode] => IDJKT_00094
            [Name] => Best Western Plus Lex Cebu        
            [Currency] => USD
            [TotalRate] => 65       
        )
    [2] => Array
        (
            [HotelNo] => 3           
            [HCode] => IDJKT_00102
            [Name] => Best Western Sand Bar           
            [Currency] => USD
            [TotalRate] => 93
        )
    [3] => Array
        (
            [HotelNo] => 4           
            [HCode] => IDJKT_00106
            [Name] => Goldberry Suites & Hotel           
            [Currency] => USD
            [TotalRate] => 51     
        )
)

总房价标签是酒店价格

我想找到所有酒店中最低的价格

如何找到所有酒店中最低的价格?

任何帮助非常感谢

干杯

$cheapesthotel = array();
foreach($data['SearchAvailResponse']['Hotel'] as $hotel){
    if($cheapesthotel == array()){
        $cheapesthotel = $hotel;
    } elseif ($hotel['TotalRate'] < $cheapesthotel['TotalRate']){
        $cheapesthotel = $hotel;
    }
}
function getMin($array)
{
$currentMin = 10000; 
$minObject = Array();
foreach($array as $val)
{
    if($val[totalRate] < $currentMin)
    {
        $minObject = $val;
    }

}
return minObject;
}