Reputation: 129
I have a dynamic URL, for example:
"up/some_images/profile_image_15/200.png"
Is there a command that can give me the path:
"up/some_images/"
?
Upvotes: 1
Views: 84
Reputation: 13484
Try this dirname — Returns parent directory's path
<?php print_r(pathinfo(pathinfo("up/some_images/profile_image_15/200.png")["dirname"])["dirname"]);
Reputation: 57693
Yes, use dirname()
dirname()
$path = "up/some_images/profile_image_15/200.png" $grandparentdir = dirname(dirname($path)); // "up/some_images"
If you want the trailing / you will have to add it yourself.
/
Upvotes: 3