4
Get domain name without Tld
Get domain name without Tld with PHP
$domain = 'dailymail.co.uk';
$dots = substr_count($domain, '.');
if($dots == 1){
$results = preg_split('/(?=.[^.]+$)/', $domain);
echo $results[0];
}
if($dots == 2){
$results = preg_split('/(?<=[^0-9])[.](?<![0-9])/', $domain);
echo $results[0];
}
Interserver | Standard & VPS Cloud Hosting | $2.50 /Month
Flexible VPS hosting platform to deploy your online projects.
Economical and balanced between processor cores, memory and storage
rated 4 times
(4)
(0)
comments: 0 / hits: 3535
/ 6 years ago, fri, sep 16, 16, 01:27:33
More From
» PHP
Comments
There are no comments for this Snippet yet