Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124456 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 61E721A00B7 for ; Wed, 17 Jul 2024 08:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721204505; bh=ABxqudyRIxsJp9HnZPaxTkqLomp74pmu3488zgYc4b4=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc:From; b=IReOr+E6r3M7DuF4rtylD9Hm4B9KMmDt2p46/a4NKl9cTTXrNrkb0oGBJlpKQmf9t O2fHIhbUYft8oDa+0xpvfXwWPt+quuRwjxmDTudCZ1FwLJRNezWXa/ojG4oDXWbIVV 5L/3Apy9RNlNi/xb68WwWXtHhWVHDlLiNCuvUPc5BhMUzxShj4LvflSgYAgV+/mxy0 MSYJjCLmpFOlFxFSyCenWXXMljuaFSju7rGsfm2ruY/wl2J8nJyBADvp98mydCe5U9 uNYbVPU/u5EyEj+xlNrhBCz611ASBsr69fYpnIxBw16ufhUm+iKmk9OBuIlUPFwi47 Vwu8GuPiRqqsw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 88B641805D0 for ; Wed, 17 Jul 2024 08:21:44 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,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 mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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:21:44 +0000 (UTC) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a77c9c5d68bso741980766b.2 for ; Wed, 17 Jul 2024 01:20:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721204413; x=1721809213; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=ABxqudyRIxsJp9HnZPaxTkqLomp74pmu3488zgYc4b4=; b=GW+JmptrgB2Pn2q3lhfz4+9gEw7Fu7vGUH0WmanRgB0M0aABADhXC/jb3tHrp3WSNr rYgzviO6bjhv72PBKboalMvOa0Z4NitZknREa1vXmtPgE8kKAeO7UVRx8Sp6wHIOS4ek iWebrHEPugoOsbu+zknEICF+n9A46OMwDDL04C3PoS2kMTUdg1cSrpT/H4HavmnbsjBy YG4OplAiosQR/09NmqzuF3BWSFjcfM8IiE2p3+9BMfCFnI1FoLubnGwSwwv3kH9Cc32p UFAoWbuidWVyJ3X9dRiBTA5wRI7Q1BBidXKmsq+IuPznuA/UcZ4jthjvOeNql/B/rwO3 n9RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721204413; x=1721809213; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ABxqudyRIxsJp9HnZPaxTkqLomp74pmu3488zgYc4b4=; b=KsfttNhXRKfY+xZp3hrQ0/tUJj7QkoV1QsR14ck8ocvk3cwacDpBdzFRe0nhEwHTHe z+UE0Ih8o7WGkwvegVBoVDlfA1u5QIvMAqIeop/x+ot9R1KCLDdGT2rIj0x544EDC8XO 7bQDW2MgfEcr6ohsfSt06ThXVoyiP6toLCMFX92+NC0KkFTSszyJAbMxOjsUnj/Eyus0 9yfZ9M44HUYBu5SwPY2j+hvjueU3gnAH+rcrLqWwCO97i9zXRuTzH2+SLELcy/3vgXC8 Id1VjoINgh88BEkVz1mhjKcmlg2zPh5Qwt5O8Ye/KZ2b0t3JffyClOoRoBp88lHTu20p E6mA== X-Forwarded-Encrypted: i=1; AJvYcCWFB4oe9OoiMrZY1NqXAy3AOL5sl2hlnxnnqCyWFQfLtpZry2Khmyx21fQB4/17SYr2Pr4gi7zukRm90GLXDKSsr+fy4i5Bvg== X-Gm-Message-State: AOJu0Ywx506pqaCh37o5aQjDey51jmfbhwBT/uAhNAuKzC++UyjYfbv/ SASGn2Am1ygVIhM3C75ibhz6GrUfHmGivaM2O0rAUxwwgw1dwhiyX9/juFohY9Nk3C5yrIEQBsL 5ZsDju6Dsp0g67ZAf41LVGRtAdr8= X-Google-Smtp-Source: AGHT+IHQm5Oj/DGBHrEXomfXetq+NNNiSWXC6AKK04nIV+9BSyCWpONa1szsFq0hUBVCToLtt7GgPTxyccxUlZQBgRs= X-Received: by 2002:a17:906:5f8b:b0:a77:f2c5:84a9 with SMTP id a640c23a62f3a-a7a0114a5d1mr58256366b.18.1721204412518; Wed, 17 Jul 2024 01:20:12 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <5bdbffef-4954-415d-9dae-4c9bd4ba0f22@scriptfusion.com> In-Reply-To: Reply-To: lilybergonzat+php@gmail.com Date: Wed, 17 Jul 2024 10:20:01 +0200 Message-ID: Subject: Re: [PHP-DEV] array_reduce callback key To: Rob Landers Cc: Bilge , mickmackusa , PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: lilybergonzat+php@gmail.com (Lily Bergonzat) It would make sense for it to be the last argument. My first thought was al= so that PHP doesn't usually care if you add extra arguments, but "internal callbacks" made me think they were C callbacks, and in that case I don't really know. On Wed, Jul 17, 2024 at 10:08=E2=80=AFAM Rob Landers wr= ote: > > 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. > > 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. > > On Wed, Jul 17, 2024 at 2:38=E2=80=AFAM Bilge wr= ote: > > > > On Wed, 17 Jul 2024, 01:29 mickmackusa, wrote: > >> > >> It is untrue that 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 th= at doesn't work at all when you also need the value. > > > > Cheers, > > Bilge > > > If it can be the last argument, then PHP doesn't care if you call a funct= ion with extra arguments ... at least, it usually doesn't. > > =E2=80=94 Rob