Req #65298 [Opn->Dup]: foreach/else
Edit report at https://bugs.php.net/bug.php?id=65298&edit=1
ID: 65298
Updated by: nikic@php.net
Reported by: john at brahy dot com
Summary: foreach/else
-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:
Closing as duplicate of https://bugs.php.net/bug.php?id=26411.
Previous Comments:
------------------------------------------------------------------------
[2013-07-19 18:40:14] john at brahy dot com
Description:
------------
I am requesting a feature for php. It's adding an else statement to a foreach loop
that would be executed when there are no elements to iterate over.
foreach ( $rows as $row ) {
print $row;
} else {
print "<tr><td>No Data</td></tr>";
}
Test script:
---------------
foreach ( $rows as $row ) {
print $row;
} else {
print "<tr><td>No Data</td></tr>";
}
Expected result:
----------------
when there is no data in the foreach loop it would execute the else
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65298&edit=1
Thread (2 messages)