public static function closest(array $array, string $value)
    {
        sort($array);
        $closest = $array[0];

        for ($i = 1, $j = count($array), $k = 0; $i < $j; $i++, $k++) {
            $middleValue = ((int) $array[$i] - (int) $array[$k]) / 2 + (int) $array[$k];

            if ($value >= $middleValue) {
                $closest = $array[$i];
            }
        }

        return static::value($closest);
    }
public static function closest(array $array, string $value)
    {
        sort($array);
        $closest = $array[0];

        for ($i = 1, $j = count($array), $k = 0; $i < $j; $i++, $k++) {
            $middleValue = ((int) $array[$i] - (int) $array[$k]) / 2 + (int) $array[$k];

            if ($value >= $middleValue) {
                $closest = $array[$i];
            }
        }

        return static::value($closest);
    }
public static function closest ( array $ array , string $ value ) { sort ( $ array ) ; $ closest = $ array [ 0 ] ; for ( $ i = 1 , $ j = count ( $ array ) , $ k = 0 ; $ i < $ j ; $ i ++ , $ k ++ ) { $ middleValue = ( ( int ) $ array [ $ i ] - ( int ) $ array [ $ k ] ) / 2 + ( int ) $ array [ $ k ] ; if ( $ value >= $ middleValue ) { $ closest = $ array [ $ i ] ; } } return static :: value ( $ closest ) ; }
Return the closest found value from array.

@param array  $array
@param string $value

@return mixed
Return the closest found value from array .