tags:

views:

38

answers:

3

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:

parent/child

Thanks!

+2  A: 
dirname($path)

And this is the documentation.

zneak
A: 

dirname()

Ignacio Vazquez-Abrams
+1  A: 

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'))
Ivan Peevski