Craig Smitham
Craig Smitham

Reputation: 3963

Use php to trim URL to just domain name by removing protocol and path

Given "http://google.com/path-to-page" trip to "google.com"

What php and regex would be appropriate?

Upvotes: 0

Views: 3176

Answers (1)

kennytm
kennytm

Reputation: 523684

Use parse_url and get the host part.

Upvotes: 9

Related Questions