How to get the minimum value from array row

前端 未结 6 1738
情话喂你
情话喂你 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 02:04

    function find_lowest($array){
            $new_array = array();
            foreach($array  as $key => $val ){
                if(is_array($val)){
                    $new_array[$key] = find_lowest($val);
                }else{
                    $new_array[$key] =  $val ;
                }
            }
            return min($new_array);
    
        }
        $array = array( array(  'id' => 1,
      '10xx' => 14,
      '11xx' => 32,
      '12xx' => 4
     ),
    
      array(
       'id' => 2,
      '10xx' => 13,
      '11xx' => 36,
      '12xx' => 41
     )
    );
     echo find_lowest($array);
    

提交回复
热议问题