Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128683 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 A48FA1A00BC for ; Fri, 12 Sep 2025 14:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1757686933; bh=FtCXWPhw7/23+bhH3yBojh5e92cEh0PlP2ElqNju5YQ=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=oQrJtyfgrL5LJPPWB1YNssoYmT1dHN0DWH7hXLOf2bVFWnHApxRTaT7k5P0JymjOv kF91nhljQo8bDu4lFXk0zh983sQRfpR9Ko0wfB0dhfsqXnHypeAGgxhS6T5DaPq96h prK0TlutqkkeJDRnvAEpnN+K73eghPcCmU4Efzp8T9Jj5UCYPQTIpRunB56JJgElwW VHnQgWKk3uPAXVIH+/iqBZ8t5bkQvbPaYG5xp5cqWeWvg0L9AmmSr0KHy4J60brw46 ngmoW8eBw8GjxSw/AIvxHg/fZ8GYQPtKc3R3BOk5s1f+vQdFxY/JzEOmDJBmFul84Y gYb/EL9ZYFqng== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9C1E51804FE for ; Fri, 12 Sep 2025 14:22:10 +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.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.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.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 ; Fri, 12 Sep 2025 14:22:08 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 02D441D002DF; Fri, 12 Sep 2025 10:23:33 -0400 (EDT) Received: from phl-imap-05 ([10.202.2.95]) by phl-compute-05.internal (MEProxy); Fri, 12 Sep 2025 10:23:34 -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=fm2; t=1757687013; x= 1757773413; bh=FtCXWPhw7/23+bhH3yBojh5e92cEh0PlP2ElqNju5YQ=; b=O Gskz2guK68+1b+U9tCUOLKUzmtZmGsuW0ed4mh08RiM9aOk2jpIZyJR5ztmBwQFA HOGvh3TZU76sy1UurTekCsF2yBovs3G0ewLvovrUwsqRczPyr/fGEcO49EMio14b /IsdClxVJQogYH7MeOWcO1Cn6B35D11QqPvmvN/NxrY3oQ5LEklqqkUeOzmQ8sWw Izpfb8NETiqLWR9wxoEVY8WLWjhrZOZFI9TmKstlobylP4uRhrh5JDVJAqWI9MPW jjc5wQBmFEM57lpOy3OI/gmiYBTY4CuiTJ52661oWosQxoqjmexJVVkTmdwT6/po d7VI2T6kLnR798VNWjd/Q== 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-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1757687013; x=1757773413; bh=FtCXWPhw7/23+bhH3yBojh5e92cEh0PlP2E lqNju5YQ=; b=mRcr8Lfiq72Eb8tkERHaVL+q15a6TLnckh/KwGf99kN5YUFd4Sz avwxCCkHdxIP1pl23CeFAHT8CZNmkvLYOnuPTz2XftsEs2/2Tka7x3wfJm0nWJGG OR3LeXUKNBY/ofsag+klU7Si4UAGVHHl2zhuMygXZhyAKCZU6EZj1F3lKCtO33ml pLdXGZuhYhZkKgl6I1ZsnRDujUVmi3Yfb0cTqvf/8646aOTUfBVpkCYf9/jBfxZC rie9FehrzSWWBdPea9/icIqYv2iiv+cmcrzhFSMjX2eTpyY/8a/XVRW13FTp3UsM 6hZvOfQRNsT4bEEQTa73XhU999t3tcmIn9g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvledvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuuh hsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpefoggffhffvvefkjghfufgtsegr tderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghoth htlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnhephfevledtgffftddvfeetffeg uddufedugfdvueeghfffheejhfdvhfetvdfhgeelnecuffhomhgrihhnpegrsghouhhtrd hmvgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehr ohgssegsohhtthhlvggurdgtohguvghspdhnsggprhgtphhtthhopeefpdhmohguvgepsh hmthhpohhuthdprhgtphhtthhopeguuhhsrghnkhhrvghhvghlsehgmhgrihhlrdgtohhm pdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvthdprhgtph htthhopehkghhuvghsthesphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 84436182007E; Fri, 12 Sep 2025 10:23:33 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: ANe1BaxgIPQo Date: Fri, 12 Sep 2025 16:23:12 +0200 To: =?UTF-8?Q?Du=C5=A1an_Krehe=C4=BE?= , "Ken Guest" Cc: internals@lists.php.net Message-ID: <23fc3c05-f238-44d5-9a27-778c73db4a23@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC proposal] Syntactic sugar for array push() Content-Type: multipart/alternative; boundary=6dc6f4da09db42b5a460aa47d4b57ece From: rob@bottled.codes ("Rob Landers") --6dc6f4da09db42b5a460aa47d4b57ece Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Sep 12, 2025, at 13:06, Du=C5=A1an Krehe=C4=BE wrote: > Hm, I didn't know about $array[] =3D 1;. >=20 > It would make sense if it were: $a[+] for push() and $a[-] for pop(). >=20 > pi 12. 9. 2025 o 12:35 Ken Guest nap=C3=ADsal(a): >> But we already have $array[] =3D 1; - are you unaware of it or is the= re some other benefit to what you are suggesting? >>=20 >> What might interest people would be a syntactic sugar/shorthand for a= rray_pop but I have no idea what that might look like. >>=20 >> On Fri, 12 Sept 2025 at 11:21, Du=C5=A1an Krehe=C4=BE wrote: >>> A proposal to add syntactic sugar for array_push() in PHP. >>>=20 >>> Syntax: >>> // now >>> array_push($array, 1); >>>=20 >>> // new syntax >>>=20 >>> $array[+]=3D1; >>>=20 >>>=20 >>> Du=C5=A1an Krehe=C4=BE >>>=20 >>=20 >>=20 >> -- >> http://about.me/kenguest/ I'd personally rather have sugar for array_unshift and array_shift, than= pop and push. =E2=80=94 Rob --6dc6f4da09db42b5a460aa47d4b57ece Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Fri, Sep 12, 2025, at 13:06, Du=C5=A1an Krehe=C4=BE= wrote:
Hm, I di= dn't know about $array[] =3D 1;.

It would make sense if it were: $a[+] for push() a= nd $a[-] for pop().

pi= 12. 9. 2025 o 12:35 Ken Guest <kguest@php.net> nap=C3=ADsal(a):
But= we already have $= array[] =3D 1; - are you unaware of it or is there some other ben= efit to what you are suggesting?

What migh= t interest people would be a syntactic sugar/shorthand for array_pop but= I have no idea what that might look like.

On F= ri, 12 Sept 2025 at 11:21, Du=C5=A1an Krehe=C4=BE <dusankrehel@gmail.com> w= rote:
A proposal to add syntactic sugar for array_push() in PHP= .

Syntax:
// now
array_push= ($array, 1);

// new syntax

$array[+]=3D1;


Du=C5=A1an Krehe=C4=BE

=


--

I'd personally rather hav= e sugar for array_unshift and array_shift, than pop and push.
=
=E2=80=94 Rob
--6dc6f4da09db42b5a460aa47d4b57ece--