Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $path = "/home/somesite/public_html/wp-content/themes/some-theme";
- echo getBase($path); /* /home/somesite/public_html/ */
- function getBase($path) {
- $i = substr($path,-1) == '/' ? 4 : 3;
- $end = strlen($path);
- $offset = 0;
- while($i > 0) {
- $end = strrpos($path, '/', -$offset);
- $offset = strlen($path) - $end+1;
- $i--;
- }
- return substr($path, 0, $end+1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement