All pastes #120486 Raw Edit

Miscellany

public php v1 · immutable
·published 2006-08-07 11:03 UTC
rendered paste body
function parseDomainName($host){        static $tlds = array('.com', '.net', '.org');         foreach ($tlds as $tld)       {                if (preg_match('/^(.*)' . preg_quote($tld) . '$/i', $host, $matches))                {                        $name_parts = explode('.', $matches[1]);                        return array_pop($name_parts) . $tld;                }        }        return false;} $urls = $linkarray[1];foreach ($urls as $url){    $url_parts = parse_url($url);    $domain = parseDomainName($url_parts['host']);    echo $domain;}