Q:

Max() with different label array

This is my code for function, each variable has different label with array: I want to find max value from this code.
      $user_id = Auth::user()->id;
    $first_hour = DB::table('finaltrade')
        ->select(DB::raw('count(*) as first'))
        ->join('exchanges', 'finaltrade.exchange_id', '=', 'exchanges.id')
        ->where('finaltrade.user_id', $user_id)
        ->whereTime(DB::raw('IF(finaltrade.buy_datetime<finaltrade.sell_datetime, finaltrade.buy_datetime, finaltrade.sell_datetime) '), '>=', DB::raw('exchanges.start_time'))
        ->whereTime(DB::raw('IF(finaltrade.buy_datetime<finaltrade.sell_datetime, finaltrade.buy_datetime, finaltrade.sell_datetime) '), '<=', DB::raw("ADDTIME(exchanges.start_time, '01:00:00')"))
        ->first();

    $last_hour = DB::table('finaltrade')
        ->select(DB::raw('count(*) as last'))
        ->join('exchanges', 'finaltrade.exchange_id', '=', 'exchanges.id')
        ->where('finaltrade.user_id', $user_id)
        ->whereTime(DB::raw('IF(finaltrade.buy_datetime<finaltrade.sell_datetime, finaltrade.buy_datetime, finaltrade.sell_datetime) '), '<=', DB::raw('exchanges.close_time'))
        ->whereTime(DB::raw('IF(finaltrade.buy_datetime<finaltrade.sell_datetime, finaltrade.buy_datetime, finaltrade.sell_datetime) '), '>=', DB::raw("SUBTIME(exchanges.close_time, '01:00:00')"))
        ->first();

    $other_hours = DB::table('finaltrade')
        ->select(DB::raw('count(*) as other'))
        ->join('exchanges', 'finaltrade.exchange_id', '=', 'exchanges.id')
        ->where('finaltrade.user_id', $user_id)
        ->whereRaw('finaltrade.created_at NOT BETWEEN exchanges.start_time AND DATE_ADD(exchanges.start_time, INTERVAL 1 HOUR)')
        ->whereRaw('finaltrade.created_at NOT BETWEEN exchanges.close_time AND DATE_SUB(exchanges.close_time, INTERVAL 1 HOUR)')
        ->first();

    $allTrades = array($first_hour,  $last_hour,$other_hours );
    $max =0;
    Foreach($allTrades as $key => $val){
        $temp = max($val);
        If($temp > $max){
            $max = $temp;
            $place = $key . " => " . Key($val);
        }
    }

    Echo $max;
    Echo "\n" . $place;

How to get max value from this type of array in arrays?
Every array has different name : first, last and other
this is result of variable:

A:

Use corected code
$allTrades = array($first_hour,  $last_hour,$other_hours );
$max = 0;
$property = '';

foreach ($allTrades as $stdObject) {
    $propertyValues = get_object_vars($stdObject);
    foreach ($propertyValues as $prop => $value) {
        if ($value > $max) {
            $max = $value;
            $property = $prop;
        }
    }
}

echo $max;
echo $property;

or one step less if know $first_hour object structure 
$allTrades = array($last_hour,$other_hours );
$max = $first_hour->first;
$property = 'first';

foreach ($allTrades as $stdObject) {
    $propertyValues = get_object_vars($stdObject);
    foreach ($propertyValues as $prop => $value) {
        if ($value > $max) {
            $max = $value;
            $property = $prop;
        }
    }
}
echo $max;
echo $property;

