What I want
I want to get from a URL
the domain
part so from http://example.com/
-> example.com
Assumes that http://
prefixes everything.
$tmp = explode("/", $url);
$domain = $tmp[2];
$tmp = parse_url($url);
$url = $tmp['host']
This is like the regex from theraccoonbear but with support for HTTPS domains.
if (preg_match('/https?:\/\/([^\/]+)\//i', $target_string, $matches)) {
$domain = $matches[1];
}