I would like to get the host name of any url for example if i've the following url
$url = "http://www.google.com";
then i want to get only google
what is after dot .
and before extension dot .
so that it can be applied for all types of urls.
so the results should be google
! i think this might needs regex or somehow
any idea how to do it , Thanks.
You should have a look at PHP's parse_url() function which returns an associative array of the various components that constitute a URL.
Will echo the following array.
The above function will just give you a start. Check into the following Stackoverflow archives on how to take it up from here.
PHP Getting Domain Name From Subdomain
Get domain name (not subdomain) in php
PHP function to get the subdomain of a URL
EDIT (few more archives - I'm not sure what you googled/tried)
how to get domain name from URL
Extract Scheme and Host from HTTP_REFERER
You can try
Output