PHP How to remove last part of a path

后端 未结 5 1994
太阳男子
太阳男子 2020-12-01 17:51

I have a path like this:

parent/child/reply

How do I use PHP to remove the last part of the path, so that it looks like this:

pare

5条回答
  •  盖世英雄少女心
    2020-12-01 18:22

    dirname(). You can use it as many times as you'd like

    • to get parent/child - dirname('parent/child/reply')
    • to get parent - dirname(dirname('parent/child/reply'))

提交回复
热议问题