Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127063 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 B632C1A00BC for ; Mon, 7 Apr 2025 00:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743986742; bh=qVWbXLOKzeiQcyuyWXlNyJeMXOqJO7kiIdnvE2iuwtk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NDq2gbiZDpymBx9A+xha4wtCbyKyHcdIBboZnIuOn7pG7mvokF1Jt1baIMOQVrpNu RbWEhbigj0gR7+wg7kEsnD/glPfcf0D+jI7Uvyq3AfEOS/WbLSC+Z1qLaRMEJ9Sj0I ZvZppn4c0HjdXvb0oDzFLb2j2yP6IbCAwaMc6+uddxgyXvB7zhj2sfkJQE5srqMs+w vQ48mLsN9sHFz0wM2AzDg+Jf89s6qe9K01K0rTMl+GJdNz4CInnDeD+PW+fZe9gXfZ 4X3b40OslV0KEDHeBMO5zLhaexFxO/9AEDBr51+uHG2ibueYmFdBzgPWIhq8xuJmvg Jw2X+ByQKMO7Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9ADCB180068 for ; Mon, 7 Apr 2025 00:45:40 +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.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from forward500b.mail.yandex.net (forward500b.mail.yandex.net [178.154.239.144]) (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 ; Mon, 7 Apr 2025 00:45:39 +0000 (UTC) Received: from mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net [IPv6:2a02:6b8:c27:153f:0:640:5e4f:0]) by forward500b.mail.yandex.net (Yandex) with ESMTPS id 5C3FC60E65 for ; Mon, 7 Apr 2025 03:48:02 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 1mPs67hLba60-mbLqsAMU; Mon, 07 Apr 2025 03:48:01 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=php.watch; s=mail; t=1743986881; bh=qVWbXLOKzeiQcyuyWXlNyJeMXOqJO7kiIdnvE2iuwtk=; h=To:Subject:Message-ID:References:Date:From:In-Reply-To:Cc; b=tgT9G4sHaJrEUcmjDpgpyqiu8T9MfqCAHLqDUPynsU/pZPLGSX9cSXWVTO8FD0NAQ wif1W7eGqSwowoyx553sfAZFe7qfdz09ZyUSvjo498Va2/oIeZ+dsvDtKepcn+6iuy 6a8x3gLtEDzUpuNG9e6wEZsH77vIZDJcV8R19ZkE= Authentication-Results: mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net; dkim=pass header.i=@php.watch Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-ac2aeada833so752726666b.0 for ; Sun, 06 Apr 2025 17:48:01 -0700 (PDT) X-Gm-Message-State: AOJu0YzEsFwQm5a7XYRhnMvCMcnIeSI7dRYn7ffhOIC/EkRt37Sqk+uC LZm1YvTXY8cQLSHlvc/CndjWWigg8e1Hzpcz6GMiNSSsveoG2oQmifFuatyvS2HwZpSgtGIEdkO udDLoOA3m977BTCIEdouJo11/hgU= X-Google-Smtp-Source: AGHT+IF+zqfmbp16CQRqgUqEjsFD9Vh37eqBM/rPtWxP76u4obj+Urh2e+zZ0Wq1MEDSi+/eGwC3gpEMopHhGJqBtP8= X-Received: by 2002:a17:907:7f86:b0:ac1:791c:153a with SMTP id a640c23a62f3a-ac7d3017b18mr863837466b.27.1743986881018; Sun, 06 Apr 2025 17:48:01 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <51fcec92-b2ae-482e-920f-c6c991b526c5@gmail.com> <9da1bf0b-482a-441d-9f16-6e94ffc9c871@scriptfusion.com> In-Reply-To: <9da1bf0b-482a-441d-9f16-6e94ffc9c871@scriptfusion.com> Date: Mon, 7 Apr 2025 07:47:35 +0700 X-Gmail-Original-Message-ID: X-Gm-Features: ATxdqUGqEiuSvyBzPSKKK90IIcSc1WR5i2JI8iZNG9Ofzcb0ZonsGAQOKJa4P8E Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] array_first() and array_last() To: Bilge Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: ayesh@php.watch (Ayesh Karunaratne) > On Mon, Apr 7, 2025 at 2:05=E2=80=AFAM Bilge wro= te: > ... [snip] I suggest first proving there is a > legitimate need. I did a quick GitHub search for a common pattern of accessing an array value by using the `array_key_first` and `array_key_last` functions: ```php $value =3D $arr[array_key_first($results)]; ``` - `[array_key_first(`: over 3,700 results[^1] - `[array_key_last(`: over 4,300 results[^2] All of these hits can benefit from the proposed `array_first` and `array_la= st`.