public static function firstHigher(
        array $list,
        float $min = null,
        float $max = null
    ) {
        $bounded_list = array_merge([$min ?? 0, $max ?? 1], $list);

        $min = min($bounded_list);
        $max = max($bounded_list);

        $result = null;
        $higher = $min;

        foreach ($list as $key => $value) {
            $value = Utils::numberLimit($value, $min, $max);
            if ($value == $max) {
                return $key;
            } elseif ($value > $higher) {
                $result = $key;
                $higher = $value;
            }
        }

        return $result;
    }
public static function firstHigher(
        array $list,
        float $min = null,
        float $max = null
    ) {
        $bounded_list = array_merge([$min ?? 0, $max ?? 1], $list);

        $min = min($bounded_list);
        $max = max($bounded_list);

        $result = null;
        $higher = $min;

        foreach ($list as $key => $value) {
            $value = Utils::numberLimit($value, $min, $max);
            if ($value == $max) {
                return $key;
            } elseif ($value > $higher) {
                $result = $key;
                $higher = $value;
            }
        }

        return $result;
    }
public static function firstHigher ( array $ list , float $ min = null , float $ max = null ) { $ bounded_list = array_merge ( [ $ min ?? 0 , $ max ?? 1 ] , $ list ) ; $ min = min ( $ bounded_list ) ; $ max = max ( $ bounded_list ) ; $ result = null ; $ higher = $ min ; foreach ( $ list as $ key => $ value ) { $ value = Utils :: numberLimit ( $ value , $ min , $ max ) ; if ( $ value == $ max ) { return $ key ; } elseif ( $ value > $ higher ) { $ result = $ key ; $ higher = $ value ; } } return $ result ; }
Returns key for first highest value

@param float[] $list List of numbers between min and max
@param float   $min  Min value to test (default is 0)
@param float   $max  Max value to test (default is 1)

@return mixed $list key
@return null  If no value was higher than $min
Returns key for first highest value