Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128681 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 6C0CC1A00BC for ; Fri, 12 Sep 2025 11:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1757675095; bh=0UwUCPbsIsRrHn8Y0IMR3AR9R1jtp0SLjaANmk5kOZU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bu7Otp/JAUuzX/5M19PlTiCf+H7UVljLq9IJQu8WASyjhwxNolm0SuOEJenEKj9Oo cLoKnIQMtwXRC8jcGWzUmfeBd5DXVBtrQsuNR2Uz5X/Kqm9FyFeMhZfP+FN9+QnBKK UtcNDif5dINDTQXfmM+H+xZAbk76tpbShLefE2tUfL6L7NctMcpexeKDE3oDYe6dwx 3R4LYCrOszZckjrZzrqkP3PL12Y+qsS0bcN/W5kHh3UpEz6geqyDg2W+0BaN4aT25U Xy76+k5JHGYyEinyf8Yu77VkiUnHUzewCAyTfFWFudCuYi43PCbrF7Ku9/Mx6L1Eui leFUMi1HiwQqA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DE43618006E for ; Fri, 12 Sep 2025 11:04:51 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 11:04:51 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-811ff57238eso17844785a.0 for ; Fri, 12 Sep 2025 04:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757675177; x=1758279977; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0UwUCPbsIsRrHn8Y0IMR3AR9R1jtp0SLjaANmk5kOZU=; b=I5lQyFGdyjiD2hOrxjq4nTihSnhD1gzx35hpmNBKdJnnuRF8BTwfuINRDGAdsDCHUe g6eZl3zEvFKDPNoA0cfLwStP+MTYMSXICw5jcBihHnLLI8YXGusqNsOGvo7xUjIntcZj F4xI8ZEDoxBAe3PwmbbPof383MO4qWS6rhZftDHv8idm4xRTuw+2UKH1INt8VYc8DPX7 zl+Bw0PZPrf4JAr2PcsCV0aCYemTJ2ex1qDLGzMGsuqonXSImpiMuZHWLAyU/oyXQzgb dTV6BNikSRdgQyiAJvYbANBjnlNiOyos/K0U6/6CAdfqtZCkAll3Fm1U3lTG3W7aLPqZ Wr/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757675177; x=1758279977; h=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=0UwUCPbsIsRrHn8Y0IMR3AR9R1jtp0SLjaANmk5kOZU=; b=kaomIjQDUgOGnrSvVFu3tMT4kYGBGg1rZh+zRbdt3e5E/Sr5WVqg6mVEnaQKZVHT9g jp6Oew/WoMz+qdoleYKRveK2yAix0TqrBYDXpRbZWVr9Bw7lDyujnBGb3k8cn75GVsOp YHiKyayPjY+BTw60wC/5a/fpXL6BDJHKhTVcHuuFadT3OkRpXX8nMaK5whz6xMixGIRz SKyeHZ/VsmClomIyC+A5Qnqpqb6Q/prnLee7Jv0zIpJxJnJDytHf9LUK2ndHsii4xY6Y bGXfv51pwRYtcu/kf3EY6HWsJJGfrKLPQ4KH8s/FEEQ1Blkb9Db9GSSZFM1E+cmOEHwI 217Q== X-Gm-Message-State: AOJu0YxdXqvlSLCti0yGisEogs0YRsTzK1BqKnin6hTMGKugX9wHrTWx qh12Z9P8S0+64/0Hya4h7AqptT1CcxkbtEwaQ7fJAPfKu6n7qgKl4h/AP0HNixHthFfIk6mPKh+ 6c6vN3ccRdKscBi1Ot0Izd0f3XPbtDg0LyYUs X-Gm-Gg: ASbGncsicoqf42/fh8C2maaD/MdxuJ3VOSoo1q0aY/aGdhzAJJVbVgLlPcJyQNaqlBy 9NC+44Jd8DXf2kBzQ4UiQ/D7t5YpIwXH7jLN3ByRhBSq/Wx6UpbeWYwkIwv2SyvDTc1/j37KIB4 HoRLUCe6bONcIbLR64HI0QZPtirpjdsI/buQsifNCbPUeskQ0aL81Dxi70tFGff0wNVXgCmsHgk H23tqNojyzj4UTXJrCeaIJNDkcSSsjixG1AtIvtU3nsSF7N X-Google-Smtp-Source: AGHT+IFdwmEbh695KhPXZsjtLduGVixlRzUWW8QrMIxwb+A78HP1gzf4qDgQ8Y1mwZ4Q1mRgUVI06Btm/+c5pAF3CGw= X-Received: by 2002:a05:622a:5ca:b0:4b5:d60c:3f33 with SMTP id d75a77b69052e-4b77d13a75cmr20257841cf.13.1757675176625; Fri, 12 Sep 2025 04:06:16 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 12 Sep 2025 13:06:04 +0200 X-Gm-Features: Ac12FXwu2P0xXPPEpvlatXui21qZBgawqCfc0sQoyROUEKTKc_zQWUx-hEeXDy8 Message-ID: Subject: Re: [PHP-DEV] [RFC proposal] Syntactic sugar for array push() To: Ken Guest Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000888c25063e98a429" From: dusankrehel@gmail.com (=?UTF-8?B?RHXFoWFuIEtyZWhlxL4=?=) --000000000000888c25063e98a429 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hm, I didn't know about $array[] =3D 1;. It would make sense if it were: $a[+] for push() and $a[-] for pop(). 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 there > some other benefit to what you are suggesting? > > What might interest people would be a syntactic sugar/shorthand for > array_pop but I have no idea what that might look like. > > 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. >> >> Syntax: >> // now >> array_push($array, 1); >> >> // new syntax >> $array[+]=3D1; >> >> Du=C5=A1an Krehe=C4=BE >> >> > > -- > http://about.me/kenguest/ > --000000000000888c25063e98a429 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hm,= I didn't know about $array[] =3D 1;.

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

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

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

On Fri, 12 Sept 2025 at 11:21, Du=C5=A1an= Krehe=C4=BE <dusankrehel@gmail.com> wrote:
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



--
--000000000000888c25063e98a429--