How to get parent and child of the path in php?

Hi all. There is a way. How do I break into that below in php
/usr/local/vesta/web/rrd/db/mysql_localhost.rrd
How do I break into
/usr/
/usr/local/
/usr/local/vesta/
/usr/local/vesta/web/
......
/usr/local/vesta/web/rrd/db/mysql_localhost.rrd

Or as I this way to construct a tree for this path?
July 12th 19 at 17:23
1 answer
July 12th 19 at 17:25
function getPathTree(string $path) : array
{
 $paths = [$path];
 while('/' !== $path=dirname($path)) {
 $paths[] = $path; 
}
 return array_reverse($paths);
}
Ask a stupid question. But as it is now to perform?
$path = "path to file;
getPathTree(string $path);
Or what? - wiley_Torphy70 commented on July 12th 19 at 17:28

Find more questions by tags PHP