Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130428 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 lists.php.net (Postfix) with ESMTPS id 713D61A00BC for ; Tue, 24 Mar 2026 11:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774352333; bh=9kWz3Uur5HZ8eHdifdhz1mobCqrX0uJh0oPYeRnDc6M=; h=Date:Subject:To:References:From:In-Reply-To:From; b=N6w8UoXiSMNUIc/ZvqqoLKOOwzLb5lKAgh2yrrG/o9OFT6UACI1Upi0+Cn28I+T8H RaISohwbV/JnGxTc2U2glxey04GVO6mDSn5bqh/MA37gm7XH3wb2P/zMaUMw7780b1 cpYjw/C+ZxGRWaXBP8/C8xnNcVrHrCJZcDiHM0+8g+y7S1vEFseD0fMBl/2+Yg4d5/ AiSWdbnbkC/30a3+uCWBZuHs7keOqVz8g4xHljNKzEo5dIaTWY65jyCWM0mrbQxdua wRMFr6UIL98WdpwHerqwfD4gWmmBkBGbC8o2bdYClN8tSlkLlfDup41JUH8EM9G734 GdUoHVKe9tUPQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 84C1F1804E3 for ; Tue, 24 Mar 2026 11:38:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chuck.smtp.mailx.hosts.net.nz (chuck.smtp.mailx.hosts.net.nz [43.245.52.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 24 Mar 2026 11:38:39 +0000 (UTC) Received: from 122-57-27-239-adsl.sparkbb.co.nz ([122.57.27.239] helo=[192.168.1.68]) by chuck.smtp.mailx.hosts.net.nz with esmtpsa authed as varteg.nz (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96) (envelope-from ) id 1w505f-00CUpc-23 for internals@lists.php.net; Wed, 25 Mar 2026 00:38:31 +1300 Message-ID: Date: Wed, 25 Mar 2026 00:38:25 +1300 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Four Pragmatic Directions for PHP: Simplicity, Arrays, Performance, Concurrency To: internals@lists.php.net References: Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Hosts-DKIM-Check: none From: Weedpacket@varteg.nz (Morgan) On 2026-03-24 23:08, 沉默领域、 wrote: > > // Proposed > $names = array_pluck($users, 'name'); > $names = array_where($users, fn($u) => $u->active); > $first = array_first($users); > $grouped = array_group_by($users, 'role'); > $compact = array_compact($data); > Of those, array_compact() is obscure in its purpose, and of the others one exists under the suggested name and three of the others exist under different names. array_group_by() is the only one that isn't already implemented. I think it means: $roles = array_unique(array_column($users, 'role')); $grouped = array_combine($roles, array_map(fn($r) => array_filter($users, fn($u) => $u['role']==$r), $roles)); though there are more efficient (and readable) ways of doing that. -- Optimising the implementation would be more difficult if the language were allowed to be sloppier. Conversely, tightening up the language allows improved optimisation.