function geturl($url){ $arr=parse_url($url); $file=basename($arr['path']); $ext=explode('.',$file); return $ext[count($ext)-1]; } $path='http://www.fdsa.com/dsa/fds/fd.php?id=1'; echo geturl($path);