1
1
Fork 0

Add PHP 5 compatible recursive dirname()

This commit is contained in:
Hypolite Petovan 2018-12-15 02:46:08 -05:00
commit 607f7daf51
2 changed files with 20 additions and 1 deletions

View file

@ -854,3 +854,22 @@ function validate_include(&$file)
// Simply return flag
return $valid;
}
/**
* PHP 5 compatible dirname() with count parameter
*
* @see http://php.net/manual/en/function.dirname.php#113193
*
* @deprecated with PHP 7
* @param string $path
* @param int $levels
* @return string
*/
function rdirname($path, $levels = 1)
{
if ($levels > 1) {
return dirname(rdirname($path, --$levels));
} else {
return dirname($path);
}
}