Best way to remove trailing slashes in URLs with PHP

前端 未结 4 2123
广开言路
广开言路 2021-01-31 07:40

I have some URLs, like www.amazon.com/, www.digg.com or www.microsoft.com/ and I want to remove the trailing slash, if it exists, so not j

4条回答
  •  Happy的楠姐
    2021-01-31 07:48

    You put rtrim in your answer, why not just look it up?

    $url = rtrim($url,"/");
    

    As a side note, look up any PHP function by doing the following:

    • http://php.net/functionname
    • http://php.net/rtrim
    • http://php.net/trim

    (rtrim stands for 'Right trim')

提交回复
热议问题