Adresten Alan Adı Almak

<?php
function urltemizle($url){
$domain=strtolower($url);
$domain= preg_replace(array('~^https?://~si' ,'~[/:#?;%&].*~','~.$~',),'',$domain);
if(preg_match('#^www.(.*)#i',$domain)){$domain=preg_replace('#www.#i','',$domain);}
$domain="http://".$domain;
return $domain;
}

echo urltemizle("http://phpstate.ulusanyazilim.com/index.php");
//Çıktısı phpstate.ulusanyazilim.com

?>