rendered paste body<?phpfunction 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 = array( 'http://www.example.com/directory/', 'http://w3c.org', 'http://subdomain.example.net?name=value', 'http://www.example.com.au' );for ($i = 0; $i < count($urls); ++$i){ $url_parts = parse_url($urls[$i]); $domain = parseDomainName($url_parts['host']); echo $domain . "<br />\n";}?>