Re: Proposal for New Feature: Multi-level Directory Navigation Function
> I propose the introduction of a new function, upDir(), which simplifies the process of moving
> up multiple directory levels in a file path. This function extends the utility of the existing
> dirname() by allowing a user to specify the number of directory levels they wish to ascend in a
> single function call.
>
> Function Prototype:
>
> function upDir(int $levels = 1, string $path = __DIR__): string
>
Hi Daniel,
Since PHP 7.0, the dirname
function does in fact support a parameter
to specify the number of levels to go up, with the default being 1.
Here is the function signature:
```php
dirname(string $path, int $levels = 1): string
```
https://www.php.net/manual/en/function.dirname.php
Thread (2 messages)