I'm wanting to strip out everything from a URL but the domain. So https://i.stack.imgur.com/inhSc.jpg becomes imgur.com.
$url = 'https://i.stack.imgur.com/inhSc.jpg';
$parsedurl = parse_url($url);
$parsedurl = preg_replace('#^www\.(.+\.)#i', '$1', $parsedurl['host']);
// now if a dot exists, grab everything after it. This removes any potential subdomain
$parsedurl = preg_replace("/^(.*?)\.(.*)$/","$2",$parsedurl);
The above works but I feel like I should only being one preg_replace for this. Any idea how I may combine the two?