note 106768 added to function.parse-url

From: Date: Mon, 05 Dec 2011 16:22:12 +0000
Subject: note 106768 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-184904@lists.php.net to get a copy of this message
Here are a couple simple functions to get the root domain (example.com) from a full domain (sub.www.example.com) or url (http://www.example.com). <?php /** * Get root domain from full domain * @param string $domain */ public function getRootDomain($domain) { $domain = explode('.', $domain); $tld = array_pop($domain); $name = array_pop($domain); $domain = $name . $tld; return $domain; } /** * Get domain name from url * @param string $url */ public function getDomainFromUrl($url) { $domain = parse_url($url, PHP_URL_HOST); $domain = $this->getRootDomain($domain); return $domain; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 209.221.8.10 ---- Manual Page -- http://www.php.net/manual/en/function.parse-url.php Edit -- https://master.php.net/note/edit/106768 Del: integrated -- https://master.php.net/note/delete/106768/integrated Del: useless -- https://master.php.net/note/delete/106768/useless Del: bad code -- https://master.php.net/note/delete/106768/bad+code Del: spam -- https://master.php.net/note/delete/106768/spam Del: non-english -- https://master.php.net/note/delete/106768/non-english Del: in docs -- https://master.php.net/note/delete/106768/in+docs Del: other reasons-- https://master.php.net/note/delete/106768 Reject -- https://master.php.net/note/reject/106768 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184904) next »