Req #27612 [Opn->Dup]: "else" statement for "foreach" construct
| From: | nikic@php.net | Date: | Sat, 22 Sep 2012 09:29:14 +0000 |
| Subject: | Req #27612 [Opn->Dup]: "else" statement for "foreach" construct | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173637@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=27612&edit=1
ID: 27612
Updated by: nikic@php.net
Reported by: camka at email dot ee
Summary: "else" statement for "foreach" construct
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Any
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:
------------------------------------------------------------------------
[2004-03-16 04:05:39] camka at email dot ee
Description:
------------
"else" statement would be very useful and comfortable when the array_expression in foreach
construct is empty. There'd be no need to calculate count(array) every time you need to execute
some code in case of empty array.
Smarty has such syntax and it really helps.
Reproduce code:
---------------
$count = count($array);
foreach($array as $arr)
{
...
}
if(!$count)
{
...
}
===============================
foreach($array as $arr)
{
...
}
else //may be [foreachelse] or [elseforeach]
{
...
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=27612&edit=1