To find the parent directory of a directory in PHP, you can use the dirname()
function which returns the parent directory of a directory.
Here's an example:
main.php107 chars5 lines
In the example above, the $dir_path
variable holds the path of the directory for which we want to find the parent directory. The dirname()
function takes this path as an argument and returns the parent directory path which is stored in $parent_dir
variable. Finally, we print the parent directory path using echo
statement.
I hope this helps!
gistlibby LogSnag