Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124453 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 206E51A00B7 for ; Wed, 17 Jul 2024 00:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1721176971; bh=M2x8l9cRdy+tsu/Lh1nTltqSa7OyiXaH6x3gg6kEzmQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=c763GaVg8zG4S3uGAgVTUhWRNl/GGc3ZNKFQN0uj/iVHHlhra9QsuvY9AxE1YAprM R7iPWpsk+7WVkPHmbDpBsxJ2FqfNPlU5NdbC8v9p6pq2i1MYov9Zp0R30g16HTTkp5 6nYcGOSi0orZYlBUBOTq2ChzTBQYdEk+VM58I9WJSp2QNA1vjIZxM7VfRBKASvU/zo ZjFRKPMfLyuYwXMN8RrDOOhqISa/W5DXOt4FQbL7PGhFbE0t3zgmJr6ys436mtXKX+ KEqyT9lS7O0tVL40JtG4YpoFhhkqdDoce52GytEmyDOfkOiVXffom6ePjQZXEOOpY5 n8xBtC9f0GD/Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1093B180080 for ; Wed, 17 Jul 2024 00:42:48 +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,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-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (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 00:42:47 +0000 (UTC) Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-8036ce660e5so19235139f.1 for ; Tue, 16 Jul 2024 17:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; t=1721176877; x=1721781677; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=M2x8l9cRdy+tsu/Lh1nTltqSa7OyiXaH6x3gg6kEzmQ=; b=LjmjM3BtbHkDLxDoOdcAorFtIbtq+Mb4vynaDcIPskGm/FcZfWob4Kr9jJkFohFGtw GWdvZZKHbb5SYTmjnQ2E66WlOob1MnoCX32E714Vlt8tL6yBiVPC0ZV1RTIsggo+uBSt xuWIQW2vRr/IVwPOFpTWGL3pmqHVtBzvpJoj8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721176877; x=1721781677; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M2x8l9cRdy+tsu/Lh1nTltqSa7OyiXaH6x3gg6kEzmQ=; b=SIvUC7Mfz1s2XT+rjaoZU2vxWAzEcU/Nidc91QgbTNAibHTnRQvcTxpTOf6Va7+w/C 8cS7LPsjXNd3M4fPL5rXYPSsJJKyN6Ol372+wnUw88/8DMMsVHm31AmqImwgGrHInt9K Eohp6mu2S8YtI99fapOm08mUkXQ6afYo4Mgj5YiX924J72GmZKJgbZl5RcAa4ywZHziP nrrhTKR4aK1NXOXqBi8FZci1CmAddCuqoSRoXTSk7K56TqrAZfti8nKTWPxQnlvjxGsl 9BXCSVe/1H1O80FJNkdXItiSatTuoNOZbPxpKz7yJEYo5XnP0IiJhK0e/O0ciBZ+Cyvz AvjQ== X-Gm-Message-State: AOJu0Yw6zAi3q+ZkoKMGl3d7571ffS/Fwsmv3Lf26xXlnCOJjpvXiHEa KobzmpZVZQok8XvuHA3imrmq66TTimiN+rs5r3rz0qB6bmEX9gDvx23osC6itmuD6akZftZ840I HDavELO6nzIRD2IoimS2lcDHf/mgGtToWVwWf9tY/HSu+KkOP X-Google-Smtp-Source: AGHT+IEspRP5HeLefuRkIvjHolZp/FcHoEG2o+QdSuTiLZA/a+I2nbrKn0lnwrA8TBaT6XA2Ufw/7aYrqcKch7mKYo8= X-Received: by 2002:a05:6602:2dc8:b0:803:cc64:e0bf with SMTP id ca18e2360f4ac-8171003fa16mr32801339f.2.1721176876887; Tue, 16 Jul 2024 17:41:16 -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: <5bdbffef-4954-415d-9dae-4c9bd4ba0f22@scriptfusion.com> Date: Tue, 16 Jul 2024 18:41:06 -0600 Message-ID: Subject: Re: [PHP-DEV] array_reduce callback key To: Bilge Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: levi.morrison@datadoghq.com (Levi Morrison) On Tue, Jul 16, 2024 at 5:17=E2=80=AFPM Bilge wrot= e: > > Hi Internals, > > I just ran into a case where I needed the array key in an array_reduce() > callback, but I can't access it :( > > So I wrote a PR to fix it: https://github.com/php/php-src/pull/14986 > > What do you think? Does this need an RFC? > > Cheers, > Bilge I don't think it's reasonable to cover every use-case "nicely" in the standard library. You didn't give a real example. You might consider using array_walk or iterator_apply, or a foreach loop depending on what you need. I am curious what your real use-case is. It may be worth adding something. It might not. Hard to tell. Adding arguments to a function can mess up internal callbacks, btw, so I don't like modifying the existing function.