php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: john at brahy dot com
New email:
PHP Version: OS:

 

 [2013-07-19 18:40 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-19 20:17 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2013-07-19 20:17 UTC] nikic@php.net
Closing as duplicate of https://bugs.php.net/bug.php?id=26411.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 20:01:28 2024 UTC