Req #72148 [Com]: foreach-else construct
| From: | must at be dot valid | Date: | Tue, 10 May 2016 13:58:03 +0000 |
| Subject: | Req #72148 [Com]: foreach-else construct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200991@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72148&edit=1
ID: 72148
Comment by: must at be dot valid
Reported by: jdmnst at gmail dot com
Summary: foreach-else construct
Status: Duplicate
Type: Feature/Change Request
Package: *General Issues
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
You should really reconsider... it's much more useful than most of the other features you
implemented in the past.
Previous Comments:
------------------------------------------------------------------------
[2016-05-04 13:26:05] nikic@php.net
Duplicate of bug #46240 for foreach specifically and bug #26411 for loops generically, which is
marked as Won't Fix as the RFC https://wiki.php.net/rfc/loop_or has been declined.
------------------------------------------------------------------------
[2016-05-04 07:42:38] jdmnst at gmail dot com
Description:
------------
foreach-else construct, that if foreach-element is empty (or not iterable).
Test script:
---------------
$foo = [];
foreach ($foo as $bar) {
echo $bar;
] else {
echo 'no bar';
}
Expected result:
----------------
no bar
Actual result:
--------------
PHP Parse error: syntax error, unexpected 'else' (T_ELSE)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72148&edit=1