#42726 [NEW]: New foreach instruction :provide pseudo method with pseudo class foreach
| From: | jfcouic at hotmail dot com | Date: | Fri, 21 Sep 2007 12:28:26 +0000 |
| Subject: | #42726 [NEW]: New foreach instruction :provide pseudo method with pseudo class foreach | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-117753@lists.php.net to get a copy of this message | ||
From: jfcouic at hotmail dot com
Operating system: windows or all
PHP version: 5.2.4
PHP Bug Type: Feature/Change Request
Bug description: New foreach instruction :provide pseudo method with pseudo class foreach
Description:
------------
Could it be possible to have a new structure instruction to "foreach" ?
I know that it possible to write with existing instructions but it could
be usefull to have this one. It could easily replace some code block like
"if(){try{foreach{}catch{}}}else{}" and provide more efficient and "bug
disable" code...
See the code, it's only a purpose.
Reproduce code:
---------------
$ar = array(0=>"one", 1=>"two");
foreach($ar as $ix $v) {
catch begin {
print "<table>";
print "<caption>My array have ".count($ar)." elements</caption>";
print "<tr><th>MyH1</th><th>...</th></tr>";
}
catch end {
print "</table>";
}
catch each {
print "<tr><th>$ix</th><th>$v</th></tr>";
}
catch null {
print "oups! my array is empty";
}
catch exception $ex {
print "oups! my code is so ugly that it done an error exception.";
}
}
Expected result:
----------------
<table>
<caption>My array have 2 elements</caption>
<tr><th>MyH1</th><th>...</th></tr>
<tr><th>0</th><th>one</th></tr>
<tr><th>1</th><th>two</th></tr>
</table>
Actual result:
--------------
oups! this instruction do not exists.
--
Edit bug report at http://bugs.php.net/?id=42726&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42726&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42726&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42726&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42726&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42726&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42726&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42726&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42726&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42726&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42726&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42726&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42726&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42726&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42726&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42726&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42726&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42726&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42726&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42726&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42726&r=mysqlcfg