Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125500 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id A2D2D1A00BD for ; Wed, 11 Sep 2024 03:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726025400; bh=G4i6n6HbifJhXi6SEFeY2aZc3Z0CKB1zmpdVe0+AvLw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cG+4NrDU5GNZ7/RjvFRW9Khm7xUtl4aPj3JYlp9soM94aawpLqKEuSLCtY2yhNXT8 c7bzFQqN+gcBYJHUgQ5yDE8BOU3coF9dEjULABP/m3L9sN62O2zOP3pXGuKbsBSaNE JOFJqHxjcgiIIdTjSuZp9OqsPh9aOJoxKCaJu789Dvt9CVLaQRhAbP+BYr6y9e6Mh7 XFRI/btKQPOcTrDIXB9lA4QBhYkz1T4LjCK3gh83MXiXZDuLd0SA2aZ3mbSTFn60I3 z6ncCh5bEe26z49mxhvmBH7MMESLhs5fnOnsFQLmT68GyhtxJGYZgi7co0EVgVKHQT 9eEvv8QTjz4SA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3B7C8180053 for ; Wed, 11 Sep 2024 03:29:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from forward500a.mail.yandex.net (forward500a.mail.yandex.net [178.154.239.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 11 Sep 2024 03:29:58 +0000 (UTC) Received: from mail-nwsmtp-smtp-production-main-18.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-18.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2b:1d5:0:640:773e:0]) by forward500a.mail.yandex.net (Yandex) with ESMTPS id E1566611BD for ; Wed, 11 Sep 2024 06:27:54 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-18.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id rRZZcZ6Oda60-thZ1fc0L; Wed, 11 Sep 2024 06:27:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.watch; s=mail; t=1726025274; bh=G4i6n6HbifJhXi6SEFeY2aZc3Z0CKB1zmpdVe0+AvLw=; h=To:Subject:Message-ID:References:Date:From:In-Reply-To:Cc; b=GzYNJMO7Mgi2O1FoPB/LO9gePh/Lc7HneJYhmwCHh9wk9paooibjicf1Nbbf+YIT5 fQ7bf+86F5eeKMj14oC2fMT8NHb0ZPdbf6BiegbNtxFdh2d0nBfTwN5DznBmy2XY0F JEi78JU89KAlD4Z+vG8ymyri1bdwLucBLTuyf/vM= Authentication-Results: mail-nwsmtp-smtp-production-main-18.vla.yp-c.yandex.net; dkim=pass header.i=@php.watch Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5bf01bdaff0so7062705a12.3 for ; Tue, 10 Sep 2024 20:27:54 -0700 (PDT) X-Gm-Message-State: AOJu0Yw+OMjvvB6hZQY8HsFs5QCs69ffHFze3t2nJZxPt73pr2cuRomu 98+3PTT9e0H0lU6bxHho8ip+tPBHFtv9WL5s7JNm+IVYcivY3rAVxH+S1vDSIYa/D8/uenePfyR o/nM45POdqvdmGaOmwwRMQmOn+0I= X-Google-Smtp-Source: AGHT+IEbCUpz2gsogKWSGvTdQuALg9s7HD0A2iOAkvWw2krhoPmbfhZfq8vnEVtFLh9Z0HH35RrCjk2+jsNlYkJeJDc= X-Received: by 2002:a05:6402:40cd:b0:5c3:cc7d:c2a0 with SMTP id 4fb4d7f45d1cf-5c3eab80751mr8966937a12.0.1726025273604; Tue, 10 Sep 2024 20:27:53 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <67337073-F5EE-4432-AC61-2A4CC086E12B@gmail.com> In-Reply-To: <67337073-F5EE-4432-AC61-2A4CC086E12B@gmail.com> Date: Wed, 11 Sep 2024 10:27:25 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PHP-DEV] Proposal for New Feature: Multi-level Directory Navigation Function To: Daniel Baldwin Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: ayesh@php.watch (Ayesh Karunaratne) > I propose the introduction of a new function, upDir(), which simplifies t= he process of moving up multiple directory levels in a file path. This func= tion extends the utility of the existing dirname() by allowing a user to sp= ecify the number of directory levels they wish to ascend in a single functi= on call. > > Function Prototype: > > function upDir(int $levels =3D 1, string $path =3D __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 =3D 1): string ``` https://www.php.net/manual/en/function.dirname.php