src/SemaltBlocker/Domainparser.php
public static function getRootDomain($url)
    {
        $host = $domain = self::getHostname($url);
        $root = false;

        if (($dotsCount = substr_count($host, '.')) > 0) {
            $last = $domain;
            while ($dotsCount > -1) {
                if (self::isHostInSuffixList($domain)) {
                    $root = $last;
                    break;
                }
                $last = trim($domain, '.');
                $domain = substr($last, strpos($last, '.'));
                $dotsCount = $dotsCount - 1;
            }
        }

        return $root;
    }
public static function getRootDomain($url)
    {
        $host = $domain = self::getHostname($url);
        $root = false;

        if (($dotsCount = substr_count($host, '.')) > 0) {
            $last = $domain;
            while ($dotsCount > -1) {
                if (self::isHostInSuffixList($domain)) {
                    $root = $last;
                    break;
                }
                $last = trim($domain, '.');
                $domain = substr($last, strpos($last, '.'));
                $dotsCount = $dotsCount - 1;
            }
        }

        return $root;
    }
public static function getRootDomain ( $ url ) { $ host = $ domain = self :: getHostname ( $ url ) ; $ root = false ; if ( ( $ dotsCount = substr_count ( $ host , '.' ) ) > 0 ) { $ last = $ domain ; while ( $ dotsCount > - 1 ) { if ( self :: isHostInSuffixList ( $ domain ) ) { $ root = $ last ; break ; } $ last = trim ( $ domain , '.' ) ; $ domain = substr ( $ last , strpos ( $ last , '.' ) ) ; $ dotsCount = $ dotsCount - 1 ; } } return $ root ; }
Extracts lower-case ASCII root domain from URL if it is available and valid, returns false otherwise.

@param string $url

@return false|string
Extracts lower - case ASCII root domain from URL if it is available and valid returns false otherwise .