|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-07-19 20:17 UTC] nikic@php.net
-Status: Open
+Status: Duplicate
[2013-07-19 20:17 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
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