PHP - strip URL to get tag name

前端 未结 4 875
耶瑟儿~
耶瑟儿~ 2021-01-28 06:24

I need to strip a URL using PHP to add a class to a link if it matches.

The URL would look like this:

http://domain.com/tag/tagname/

Ho

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-28 07:07

    combine some substring and some position finding after you take the last character off the string. use substr and pass in the index of the last '/' in your URL, assuming you remove the trailing '/' first.

提交回复
热议问题