Reputation: 479
I'm using PHP/Symfony2 and need to get the host substring from a URL string.
Possible input:
http://some.url/
Desired output (without schema and slashes):
some.url
The simplest solution is str_replace(["http://", "https://", "/"], ['','', ''], 'http://some.url');
but I don't like it.
Upvotes: 0
Views: 39
Reputation: 722
there is builtin php function doc:
$domain = parse_url($url, PHP_URL_HOST);
Upvotes: 4