How to get the grandparent directory's path in PHP? -
i'm using dirname( $path )
parent directory's path. example:
$path = 'home/grandparent/parent/child.php'; $dir = dirname( $path ); // home/grandparent/parent
how can grandparent directory's path?
for example, need get:
home/grandparent
note, i'm coding inside child.php , need use path string
in file.
bolt on call dirname
, if
$path = 'home/grandparent/parent/child.php'; $dir = dirname( $path );
gives you
home/grandparent/parent
then
dirname(dirname($path));
gives you
home/grandparent
Comments
Post a Comment