I need to build a function which parses the domain from a URL.
So, with
http://google.com/dhasjkdas/sadsdds/sdda/sdads.html
or
This will generally work very well if the input URL is not total junk. It removes the subdomain.
$host = parse_url( $Row->url, PHP_URL_HOST );
$parts = explode( '.', $host );
$parts = array_reverse( $parts );
$domain = $parts[1].'.'.$parts[0];
Example
Input: http://www2.website.com:8080/some/file/structure?some=parameters
Output: website.com