3v4l.org

run code in 300+ PHP versions simultaneously
<?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://eye-talk.org/") == "eye-talk.org" ); assert( get_domain("http://www.eye-talk.org/") == "eye-talk.org" ); assert( get_domain("http://www.eye-talk.org.cc/") == "eye-talk.org.cc" );

preferences:
81.98 ms | 402 KiB | 5 Q