In this code for file manager script I want to set the custom or optionality path/directory to view his folders and files.
So, how can I do that ?
function get_absolute_path($path) {
$path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
$parts = explode(DIRECTORY_SEPARATOR, $path);
$absolutes = [];
foreach ($parts as $part) {
if ('.' == $part) continue;
if ('..' == $part) {
array_pop($absolutes);
} else {
$absolutes[] = $part;
}
}
return implode(DIRECTORY_SEPARATOR, $absolutes);
}