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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -