Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124455 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 46AF11A00B7 for ; Wed, 17 Jul 2024 08:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721203787; bh=msIAaorc2uMEOp2YxgO7ctZqmSgsIh//DxB7d982cUE=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=kd3B2/lVfQE0BGD5n4PUsPhoaSUhSqLPHi60N4fiE9o53VrI2H00R0ld8VYPoqJbM Nygm0dWJtgMiIPVY1xtU0UMs3utiOkEkRYUX0DQA2XzaST86+XbriLUVbVJvpg8kdd bZaFe6cxDbGBLLJtDaRBQfSw58+HhsWNVBj1DOdlcUd6Szqgpo9pDyyoBbBTmvDHqK aysTNThywKP5qv33Gdpk0uI9/SM76FVNENYMa7eo5/qxBKb2oRzXUK2x/5oJcaFaYx iqFdPrRcD288cZqgnVhW0gtuBixam05oPSGDhEpxx2Uso31sWdMKMIAZ2+nQbxskP9 PM8sKtG3CdijQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DF6101806B0 for ; Wed, 17 Jul 2024 08:09:46 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout3-smtp.messagingengine.com (fout3-smtp.messagingengine.com [103.168.172.146]) (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, 17 Jul 2024 08:09:46 +0000 (UTC) Received: from compute9.internal (compute9.nyi.internal [10.202.2.228]) by mailfout.nyi.internal (Postfix) with ESMTP id E80DF138031A; Wed, 17 Jul 2024 04:08:15 -0400 (EDT) Received: from wimap25 ([10.202.2.85]) by compute9.internal (MEProxy); Wed, 17 Jul 2024 04:08:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc: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=fm3; t=1721203695; x= 1721290095; bh=msIAaorc2uMEOp2YxgO7ctZqmSgsIh//DxB7d982cUE=; b=K YQJQA4ZKNa5TCMnvMSlLhpTiOMlJiCYoeJ9I4/KQ1qe+h+sk7/7X+9iwTW2C7JnA MBW6ZQ1HNBw1Q+vivhbqTU+NQ47oHtm9iW8tbS+jXqbpzmJfEFE9z9Zs2m4awUHQ eZOj+IAcV2bweBLH68bxskUrhWc9bYLWFGHPMpcGx3IV1JeWaJw58R8eHWU2+e/e dHC61/6O2Xpn6Zcq3t4VPXxYDaq59Fa1J4C6h1qaIonuHzB3r/ClOsHntysF+qV0 h4gizA8c54zpji71Lz3/M/ZxgJTfAIAI6uPCbHJ/SPsJXP8ozqw/6PtqCbLBOpiV AWrKaJON1waIvryCg3Iyw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1721203695; x=1721290095; bh=msIAaorc2uMEOp2YxgO7ctZqmSgs Ih//DxB7d982cUE=; b=q1h/bMIIJS4w9eh7xKvLTeT5txMv+KowzJrlaoWXs969 7kEvcVoK3bjJ+dVKoiPPX9gyTOIQVv+TfIg0kd+nD2Y6aVtQh04NcBRPP9uqI9of FYUdfZGm/g9DTA1+FDjdU9/jj+zU9CfWSP+bWBv8f//y+VrW+VjCM9CAtFB0EHpC 1eFAYWSLwh11jshyb/UQh8/armi4AzLfoWG4+TC9LZ4EE4WOLCscUey5yWb/xytD m+QvjrsuLWLxENb33fXTDVizLuHCgIPb+Pj0F0EA72ooe9nCN9RwqaE22w5lTEcD OTjSgn5vHhx5Tj2qLwrWDINXtqwmsf4Edum8b9Zvgg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrgeehgddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho sgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrf grthhtvghrnhepvdehkeetleevteefveegkefgffdvuefhleevhedvteeigfegtdefjeeh tefghfeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprhhosgessghothhtlhgvugdrtghouggvsh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 52A53104005F; Wed, 17 Jul 2024 04:08:14 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-568-g843fbadbe-fm-20240701.003-g843fbadb Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Message-ID: In-Reply-To: References: <5bdbffef-4954-415d-9dae-4c9bd4ba0f22@scriptfusion.com> Date: Wed, 17 Jul 2024 10:07:52 +0200 To: "Lily Bergonzat" , Bilge Cc: mickmackusa , "PHP Internals List" Subject: Re: [PHP-DEV] array_reduce callback key Content-Type: multipart/alternative; boundary=540c44e5460245cea57533916f656d61 From: rob@bottled.codes ("Rob Landers") --540c44e5460245cea57533916f656d61 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jul 17, 2024, at 09:55, Lily Bergonzat wrote: > While it *is* indeed a workaround, you can very easily > access the values of the array from the keys, since that > literally is what the keys are for. >=20 > While I also think it's weird that not all php array functions > with callbacks do pass the key as an argument, and while > I also stumbled upon that problem in the past myself > multiple times, I also think it is worth taking the time to > consider what other people from this mailing list are > bringing up. If it could indeed break internal callbacks, > then I think using the workaround could be a better idea > than potentially breaking other things. >=20 > On Wed, Jul 17, 2024 at 2:38=E2=80=AFAM Bilge = wrote: > > > > On Wed, 17 Jul 2024, 01:29 mickmackusa, wrot= e: > >> > >> It is untrue that you "can't access it"; you just need to use an ar= ray of keys as the input array. > > > > It is absolutely true and your workaround is just that; a workaround= that doesn't work at all when you also need the value. > > > > Cheers, > > Bilge >=20 If it can be the last argument, then PHP doesn't care if you call a func= tion with extra arguments ... at least, it usually doesn't. =E2=80=94 Rob --540c44e5460245cea57533916f656d61 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Jul 17,= 2024, at 09:55, Lily Bergonzat wrote:
While it *is* indeed a workaround, you can v= ery easily
access the values of the array from the keys, s= ince that
literally is what the keys are for.

While I also think it's weird that not all php array fu= nctions
with callbacks do pass the key as an argument, and= while
I also stumbled upon that problem in the past mysel= f
multiple times, I also think it is worth taking the time= to
consider what other people from this mailing list are<= br>
bringing up. If it could indeed break internal callbacks,<= br>
then I think using the workaround could be a better idea
than potentially breaking other things.

<= /div>
On Wed, Jul 17, 2024 at 2:38=E2=80=AFAM Bilge <bilge@scriptfusion.com> wrote:
<= /div>
>
> On Wed, 17 Jul 2024, 01:29 mickmackusa= , <mickmackusa@gmail.com= > wrote:
>>
>> It is untrue t= hat you "can't access it"; you just need to use an array of keys as the = input array.
>
> It is absolutely true= and your workaround is just that; a workaround that doesn't work at all= when you also need the value.
>
> Che= ers,
> Bilge

=
If it can be the last argument, then PHP doesn't care if = you call a function with extra arguments ... at least, it usually doesn'= t.

=E2=80=94 Rob
--540c44e5460245cea57533916f656d61--