public static function cleanRut(string $rut, bool $forceUppercase = true)
    {
        // Filter the RUT string and return only numbers and verification digit.
        $filtered = preg_filter('/(?!\d|k)./i', '', $rut) ?? $rut;

        // If the filtered RUT is not empty and over the 6 characters, we're good.
        if (!empty($filtered))
            return $forceUppercase ? strtoupper($filtered) : strtolower($filtered);
    }
public static function cleanRut(string $rut, bool $forceUppercase = true)
    {
        // Filter the RUT string and return only numbers and verification digit.
        $filtered = preg_filter('/(?!\d|k)./i', '', $rut) ?? $rut;

        // If the filtered RUT is not empty and over the 6 characters, we're good.
        if (!empty($filtered))
            return $forceUppercase ? strtoupper($filtered) : strtolower($filtered);
    }
public static function cleanRut ( string $ rut , bool $ forceUppercase = true ) { // Filter the RUT string and return only numbers and verification digit. $ filtered = preg_filter ( '/(?!\d|k)./i' , '' , $ rut ) ?? $ rut ; // If the filtered RUT is not empty and over the 6 characters, we're good. if ( ! empty ( $ filtered ) ) return $ forceUppercase ? strtoupper ( $ filtered ) : strtolower ( $ filtered ) ; }
Cleans a RUT string

@param string $rut
@param bool $forceUppercase
@return string
Cleans a RUT string