Edit report at https://bugs.php.net/bug.php?id=72148&edit=1
ID: 72148
Updated by: nikic@php.net
Reported by: jdmnst at gmail dot com
Summary: foreach-else construct
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: *General Issues
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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