PHP - strip URL to get tag name

前端 未结 4 877
耶瑟儿~
耶瑟儿~ 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:03

    For your URL

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

    The PHP function to get "tagname" is called basename():

    echo basename('http://domain.com/tag/tagname/');   # tagname
    

提交回复
热议问题