From:             camka at email dot ee
Operating system: Any
PHP version:      Irrelevant
PHP Bug Type:     Feature/Change Request
Bug description:  "else" statement for "foreach" construct

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 bug report at http://bugs.php.net/?id=27612&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27612&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27612&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27612&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27612&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27612&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27612&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27612&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27612&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27612&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27612&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27612&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27612&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27612&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27612&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27612&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27612&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27612&r=float

Reply via email to