View Single Post
  #1  
Old 06-24-2006, 12:42 PM
JustBreathe JustBreathe is offline
Registered User
Join Date: Jun 2006
Posts: 59
JustBreathe is on a distinguished road
foreach missing element!

PHP Code:
function onCreated()
  {
  
temp.var = {1,2,3};
  for ( 
temp.v: temp.var )
    {
    echo( 
temp.v );
    if ( 
temp.v == 1 )
      
temp.var.remove( temp.v );
    }
  } 
Output:
PHP Code:
1
3 
That is... When you remove an index within a for ( element: array ), the following element is skipped... That is, the index of the array isn't backed up by the amount of indexes deleted/removed.
Reply With Quote