|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65298 foreach/else
Submitted: 2013-07-19 18:40 UTC Modified: 2013-07-19 20:17 UTC
From: john at brahy dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: john at brahy dot com
New email:
PHP Version: OS:


 [2013-07-19 18:40 UTC] john at brahy dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-19 20:17 UTC]
-Status: Open +Status: Duplicate
 [2013-07-19 20:17 UTC]
Closing as duplicate of
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 27 18:01:26 2020 UTC