#46240 [NEW]: Build in foreach else support
| From: | kjarli at gmail dot com | Date: | Mon, 06 Oct 2008 08:57:15 +0000 |
| Subject: | #46240 [NEW]: Build in foreach else support | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-129501@lists.php.net to get a copy of this message | ||
From: kjarli at gmail dot com
Operating system: *
PHP version: 5.2.6
PHP Bug Type: Feature/Change Request
Bug description: Build in foreach else support
Description:
------------
Each time you want to foreach an array, you first have to check with
a count or empty if you want to give a message or w/e to notify there
is no entry to an array (or object if implements like iterator).
If possible add a else option to foreach.
Reproduce code:
---------------
<?php // old style
if(count($myArray) > 0) {
foreach($myArray as $key => $value) {
}
}
//new style
foreach($myArray as $key => $value) {
} else {
// empty array/object
}
(kinda like how smarty implements it)
--
Edit bug report at http://bugs.php.net/?id=46240&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46240&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46240&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46240&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46240&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=46240&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46240&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46240&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46240&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46240&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46240&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46240&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46240&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46240&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46240&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46240&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46240&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46240&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46240&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46240&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46240&r=mysqlcfg