Parsing domain from a URL

前端 未结 18 2405
独厮守ぢ
独厮守ぢ 2020-11-22 12:26

I need to build a function which parses the domain from a URL.

So, with

http://google.com/dhasjkdas/sadsdds/sdda/sdads.html

or

18条回答
  •  耶瑟儿~
    2020-11-22 12:43

    function getTrimmedUrl($link)
    {
        $str = str_replace(["www.","https://","http://"],[''],$link);
        $link = explode("/",$str);
        return strtolower($link[0]);                
    }
    

提交回复
热议问题