Php 如何找到数组的最小值?

Php 如何找到数组的最小值?,php,Php,打印的结果($data['SearchAvailResponse']['Hotel']): TotalRate标签是酒店价格 我想找到所有旅馆中最便宜的 如何找到所有酒店中的最低价格 非常感谢您的帮助 干杯$cheapesthotel=array(); foreach($data['SearchAvailResponse']['Hotel']作为$Hotel){ 如果($cheapesthotel==array()){ $cheapesthotel=$hotel; }elseif($hotel[

打印的结果($data['SearchAvailResponse']['Hotel'])

TotalRate标签是酒店价格

我想找到所有旅馆中最便宜的

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

非常感谢您的帮助

干杯

$cheapesthotel=array();
foreach($data['SearchAvailResponse']['Hotel']作为$Hotel){
如果($cheapesthotel==array()){
$cheapesthotel=$hotel;
}elseif($hotel['TotalRate']<$cheapesthotel['TotalRate'])){
$cheapesthotel=$hotel;
}
}
函数getMin($array)
{
$currentMin=10000;
$minObject=Array();
foreach($val形式的数组)
{
如果($val[totalRate]<$currentMin)
{
$minObject=$val;
}
}
返回子对象;
}
我需要你的帮助。看这里:
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;
}