tags:

views:

244

answers:

1

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

What php and regex would be appropriate?

+6  A: 

Use parse_url and get the host part.

KennyTM
$host = parse_url($url, PHP_URL_HOST);
Mark Tomlin
Or, $_SERVER['SERVER_NAME'] will get you www.domain.com or domain.com.
Mark Tomlin