<?php function get_domain($url){ $host = parse_url( $url, PHP_URL_HOST ); $host_parts = explode(".", $host); if(count($host_parts)>2){ array_shift($host_parts); } return implode(".", $host_parts); } assert( get_domain("http://najdi.si/") == "najdi.si" ); assert( get_domain("http://www.najdi.si/") == "najdi.si" ); assert( get_domain("http://www.najdi.si.com/") == "najdi.si.com" );
You have javascript disabled. You will not be able to edit any code.