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
dirname($path)
And this is the documentation.
dirname()
. You can use it as many times as you'd like
dirname()
preg_replace("/\/\w+$/i","",__DIR__);
# Note you may also need to add .DIRECTORY_SEPARATOR at the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With