Re: Proposal for New Feature: Multi-level Directory Navigation Function

From: Date: Wed, 11 Sep 2024 03:27:25 +0000
Subject: Re: Proposal for New Feature: Multi-level Directory Navigation Function
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-125500@lists.php.net to get a copy of this message
> 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

« previous php.internals (#125500) next »