I have the following PHP code
$businessWebsite = 'http://www.times.hello.com.uk/articles/view/20.141013/local/police-killer.gets-10-more-months-over-drugs.539550';
$host = parse_url($businessWebsite, PHP_URL_HOST );
$parts = explode( '.', $host);
//$parts = array_reverse( $parts );
$domain = $parts[1].'.'.$parts[2].'.'.$parts[3].'.'.$parts[4];
print_r($parts);
echo $domain;
This echo's times.hello.com.uk
this is made up of four parts
Array
(
[0] => www
[1] => times
[2] => hello
[3] => com
[4] => uk
)
Let us say my domain is $businessWebsite = 'http://www.times.com.uk/articles/view/20.141013/local/police-killer.gets-10-more-months-over-drugs.539550';
It would echo times.hello.com..
I would end up with two dots at the end.
If the domain is $businessWebsite = 'http://www.times.com/articles/view/20.141013/local/police-killer.gets-10-more-months-over-drugs.539550';
It would echo times.com...
I would end up with three dots at the end.
How do I go solving the problem?
I want to remove the double and triple dots at the end.