Find out the name of the parent folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jak82
Forum Newbie
Posts: 11
Joined: Mon Oct 15, 2007 4:21 am

Find out the name of the parent folder

Post by jak82 »

Hi,

I have a file called index.php, I wish to get the name of the parent folder,

Any ideas on how to go about this,

Many Thanks

Chris
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post by seppo0010 »

Code: Select all

<?php
echo dirname(__FILE__); //current directory
echo dirname(dirname(__FILE__)); //parent directory
?>
jak82
Forum Newbie
Posts: 11
Joined: Mon Oct 15, 2007 4:21 am

thanks

Post by jak82 »

Many Thanks for that,

but unfortunalty that seems to return the full path, its just the last dir I need,

Like the name of it,

thanks again,

Chris
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post by seppo0010 »

ups, sorry...

Code: Select all

echo basename(dirname(dirname(__FILE__)));
Post Reply