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.

ref: http://php.net/manual/en/function.dirname.php

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

Popular posts from this blog

r - Trouble relying on third party package imports in my package -

Payment information shows nothing in one page checkout page magento -