I used:
echo basename(rtrim($id, "/")) . "/";
for the string: gallery/test_gallery_a/subgallery_1 and it returned:
subgallery_1/ instead of
gallery/test_gallery_a
This is the idea I want, but it seems to be giving me the wrong output; I want the other end of the string.
Part of this is my fault:
I mean, I want to replace a string in the format of:
gallery/test_gallery_a/subgallery_1
with
gallery/test_gallery_a
(without trailing slashes in either).