Req #61222 [NEW]: For... else construct
| From: | jeroenvandenenden at gmail dot com | Date: | Thu, 01 Mar 2012 15:27:36 +0000 |
| Subject: | Req #61222 [NEW]: For... else construct | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-167966@lists.php.net to get a copy of this message | ||
From:
Operating system:
PHP version: Irrelevant
Package: Arrays related
Bug Type: Feature/Change Request
Bug description:For... else construct
Description:
------------
It would be nice to have a for...else construct like you see in other
languages.
This makes the code more compact and readable and it avoids the necessity
to
combine an if and a for loop.
Test script:
---------------
for ($val in $array) {
echo $val.'<br />';
} else {
echo 'No values found';
}
Expected result:
----------------
In the case of an empty array, the else part would be called. Without this
construct the code would be as follows.
if (count($array) > 0) {
for ($val in $array) {
echo $val.'<br />';
}
} else {
echo 'No values found';
}
--
Edit bug report at https://bugs.php.net/bug.php?id=61222&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61222&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61222&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61222&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=61222&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61222&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=61222&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=61222&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=61222&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=61222&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=61222&r=support
Expected behavior: https://bugs.php.net/fix.php?id=61222&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=61222&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=61222&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=61222&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61222&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61222&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=61222&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=61222&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=61222&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=61222&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=61222&r=mysqlcfg