Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127064 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 D952A1A00BC for ; Mon, 7 Apr 2025 03:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743997068; bh=jzPcF8KGCuZdT5vpWFqBl6pIuYm6wd9Gd9AxJ6CqYgw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=SER+PhfktBfbh54BB9Hvf8m7RTwjngmeYm7zGO3KPnw9BSX6eegWtcBa9EKX3+CAj 2kfP4Mdpb1dd3KzPMzSeBZUu9Pk3Jn+RnNCb0wJmM0JkqDqJyAw7exFdZuL1XVXh2M tktr52yY5IsR+twUtJ4OGrMBuibqzvZJ9rpmgs7UpUv/0o4Xld+lBxQ+LnRzfELhi2 Vs85rmZXQc7t6WhxcCVCOH+z3qoFF8FQ/Uz34aNvxVlfHdYS3aAxIgBOXSQWKoVrDL i5/WiblsohA4c0rNkC9nNMqemCM5fy9o7Au9lh9f92/N7S2z2vGgD56VXwmAy+eHdh nLM/BEMpXUb+Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9A5318005B for ; Mon, 7 Apr 2025 03:37:47 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 03:37:47 +0000 (UTC) Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 0E07D2540194 for ; Sun, 6 Apr 2025 23:40:12 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-12.internal (MEProxy); Sun, 06 Apr 2025 23:40:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm2; t=1743997211; x=1744083611; bh=0QZ6SL1y418/FiGhKu7x/ T5bPE2uQqVw9Z/kS72O6Fo=; b=M8zAFTX9FKDjgfGi9dBNEMpof2WdHzUX1deNL a9qWbvdKGUXdLjwBhtYNyFrXDBBxBwmDCl2OES2t275V1TgzYoxiMIUbCFF9gloU CSelGdjRVTXcKnN7G1ea3CCX30aPqojSWd87rSWqKxCqga2R5cpJQtK2/60K0BdG MKNpuuEXMN5+fgX+ZtGxrI3ysBPEoZgSdQ5frx4r3uEk2Kcua32cccvi4JLgf1wj uIq8AgwZYKfqo/NMB3cG6jiTZfKrBNXW57Ygrm/6jF0mxEE20Abc7D9gDIeAiDOQ wKvZdWGk2o5x7c+c4L4l6KBsz4yWCaV0Kc3eJKHbhWp3F/bmg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1743997211; x=1744083611; bh=0 QZ6SL1y418/FiGhKu7x/T5bPE2uQqVw9Z/kS72O6Fo=; b=IDE/BRNOrGDwe1xRL CfHINE1Cc2oECYZJaLYPxbxog+PSbRF0ByBCypMZnBZcuqUCs+9hIUpkJUdClAhM 1KaWUVtHib0FDG4SXUMZ2TA5VOQSdfiClQW7RUW4RUIYkYbnDLyq9nxIHv/7ozeK wNbz1WL7F6OfTDXSt2ZGuez740DiGZW2CXzFuD1BNIUI7dW6qmkMM0fqnQDkAaGp Kw+AXflsl6VvqzPhKkPBQMB/R7LlRXwN7TKhQs1bS6F1xGhqmdBltPIYu2KrdHEG d4Ru5uBu1YLukPax0COVfCZoemqZrRqzw+3sCtYSSE2ggvyjMNHcAk+iBOGHeqzJ 0w9Ew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduleeludduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredt jeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeffieeivdfhvdeguddt tdegteeiueegvefhteehfeeffeetudeitdehtdegjeeuieenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlught vggthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 8B8B429C0076; Sun, 6 Apr 2025 23:40:11 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T84585c5ef0f31a52 Date: Sun, 06 Apr 2025 22:39:51 -0500 To: "php internals" Message-ID: <99a1f9a6-4e67-42c9-bbb4-401638f9c6aa@app.fastmail.com> In-Reply-To: References: <51fcec92-b2ae-482e-920f-c6c991b526c5@gmail.com> <9da1bf0b-482a-441d-9f16-6e94ffc9c871@scriptfusion.com> Subject: Re: [PHP-DEV] [RFC] [Discussion] array_first() and array_last() Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Sun, Apr 6, 2025, at 7:47 PM, Ayesh Karunaratne wrote: >> On Mon, Apr 7, 2025 at 2:05=E2=80=AFAM Bilge = wrote: >> ... [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 `arr= ay_last`. Just registering that I am all for this RFC and look forward to using it. --Larry Garfield