Archives for : 2010-12

2010
12-25

What empty foreach do in PHP

While ago I was fighting with one bug. There was code witch was working, but stop working when I add empty foreach.
  1. //that work with rest of code
  2. function fun(){
  3. $table= array();
  4. //...
  5. return $table;
  6. }
  7.  
  8. //that do not work with rest of code
  9. function fun(){
  10. $table= array();
  11. //...
  12. foreach( $table as $key => $val ){}
  13. return $table;
  14. }
  15.  
(more…)