Page 1 of 1

Find out the name of the parent folder

Posted: Mon Nov 05, 2007 6:22 am
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

Posted: Mon Nov 05, 2007 6:57 am
by seppo0010

Code: Select all

<?php
echo dirname(__FILE__); //current directory
echo dirname(dirname(__FILE__)); //parent directory
?>

thanks

Posted: Mon Nov 05, 2007 7:06 am
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

Posted: Mon Nov 05, 2007 7:10 am
by seppo0010
ups, sorry...

Code: Select all

echo basename(dirname(dirname(__FILE__)));