Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124454 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 54DB21A00B7 for ; Wed, 17 Jul 2024 07:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721203024; bh=3S2Tp2dv6tQW5SFpiJ5gYeGwGZdvDm/jYo77xhlei+c=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc:From; b=dZorvs+qZeuXhfHgV/6twJALqXEv7SllbbmRiGqWLAGsWl7idrkAA3My9hUA3gimQ 7MniR03QdADxd/lS3GylWSIWIdSKiF07lyi8fzjW5beRmvRixlG31w/pfwfYf2fsdP RI6CDnZ6GiWAe82Fp8O1CmoUBl40QtSa17/QAtYfwoMLv+8SeRg2DMMYTRI7xjsYda /MXNbDshfYYULKTw/RTUN8oyjxyBltXBPqizatfafBtySPLwj6wvoFAgclSqJIUARz PWI/W+H+VodgFMxZUi3uKhetBI4Qn2X5pe5plN/eyHegpM5MS2Zlgir6834eyRVYK+ rd65ZZSARrhEA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 63580180057 for ; Wed, 17 Jul 2024 07:57:03 +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_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 07:57:02 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5a015a79e80so479085a12.2 for ; Wed, 17 Jul 2024 00:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721202932; x=1721807732; 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=3S2Tp2dv6tQW5SFpiJ5gYeGwGZdvDm/jYo77xhlei+c=; b=m2Iue0c8rGx8hfo9IEw6WVb0MbQk4BAkspKpXM+5GYzvs/5d/Ryxu+gGeHQJgYhDOf p7O94t2NdXRfal3/oLLZGO3HSXSWPlXZNQIbpPNqK1zfxdAXh76BvkmZq7f+hBY0u5yI QnF0sJ9jg9RKOavifgzBj+1Eca70IWffa2kCkZFkHI7nwlFErQ9hQrjQIWNSvLCy9Seu 4SUXKxEQMwnYnnO7aKNV/v5BRe2EickAxQLy+iLksyTb/Q7hbYo6RicX+q3Eebd01yVJ ZEA296Kuc2bRBLoNLvMe489kDoRYnp1BtB2BrcRVSMGOhdi7/4JFLMuicB2LSCs+AJBj cmFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721202932; x=1721807732; 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=3S2Tp2dv6tQW5SFpiJ5gYeGwGZdvDm/jYo77xhlei+c=; b=RsUTgzf95D0nfCKNt7F1fYPaPPT+8iD6PurtX3eL9SahJtIGBLEG0/6DDpQRe010mv bCWAbxLtgtfiZuEZx9sTBTLJfi30W0z5mJ2V+bSdwr5gHMwp7h84eQUq+EdUBAIso/8X QhO+xAzilZRqRRJ/ac16ESKwLXcA3Ee4a3hT6/5GJbU1Gqyr7RWuVPCkImlu0ZxT+JrB fwJj/OcvqsqQOlzdPeR3tl+yOJkSRsnmDyUTSwS4YGio/fWcqK3ooN6aOiTLi4gc4EVh pfgKhWrS4XgKuVTAHkvGV0xWnjUwT/w/6krz2gM5LaRMGFly4upxUjQxSE6HMi72+Uky Kg3w== X-Forwarded-Encrypted: i=1; AJvYcCWf13LwxIj4NQNVJUk5ge3K2VcdH+cFRHXaATRnzs/vULL1DirSbHrCsAOiVka5b+DkesJCBpDus5lfDWbWJygbhF25jVO4+g== X-Gm-Message-State: AOJu0YxhLy/Fm+xIUtb7bkx4P+z5+EFvARrQHnd0XjRVbH/AU18TRqTQ 8u7jVG1J9ry3mcId66GRd366Fvo9blK3U5qnIICg8fb07OfkzgcqscvpsI9ZW+6R7o22iXbDZVY xzATsTFs4+onVmvgYBC5iOi5jOMc= X-Google-Smtp-Source: AGHT+IHk/8vZ/qpJnBg4lFHGOhIBwpueZyYpGvgfQD9zXphCyC7fXI9dE/5aqrFd86peEsGmcTLmzdYgnrqyPMBvaSc= X-Received: by 2002:a50:8d18:0:b0:57c:6ade:d8f5 with SMTP id 4fb4d7f45d1cf-5a05bcc8b8dmr929740a12.21.1721202931469; Wed, 17 Jul 2024 00:55:31 -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 09:55:20 +0200 Message-ID: Subject: Re: [PHP-DEV] array_reduce callback key To: Bilge Cc: mickmackusa , PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: lilybergonzat+php@gmail.com (Lily Bergonzat) 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 wrot= e: > > 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 o= f 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