How to get the minimum value from array row

前端 未结 6 1788
情话喂你
情话喂你 2021-01-25 01:15

I trying to get the minimum values from the any column contains \"xx\" in the column name.

Below is my code:



        
6条回答
  •  渐次进展
    2021-01-25 01:57

    $array = array(
             array(
              'id' => 14,
              '10xx' => 14,
              '11xx' => 32,
              '12xx' => 4
             ),
    
              array(
               'id' => 2,
              '10xx' => 13,
              '11xx' => 36,
              '12xx' => 41
              )
            );
    
        $lowestKey = '';
    
        foreach($array as $arra){
            foreach ($arra as $key=>$value){
                if ($key == 'id'){
                    if(($value < $lowestKey )||( $lowestKey== '')){
                    $lowestKey = $value;
                    }
                }
    
    
            }
        }
       echo $lowestKey;
    

提交回复
热议问题