views:

46

answers:

2

Hi,

I'm using Symfony 1.2.7 and Doctrine 1.1. I have $activities (sfOutputEscaperIteratorDecorator - Doctrine_Collection). I'm escaping everything on settings.yml with ESC_SPECIALCHARS method. If I weren't escaping it, it would work without any problem, so I think the problem is related with sfOutputEscaperIteratorDecorator.

If I do echo count($activities) it returns me 5

I remove several elements:

foreach($activities as $key => $a){
  if(...){
    $activities->remove($key);
  }
}

Then if I do echo count($activities) it returns me 2

However when I iterate through the elements, I still have the same 5 elements:

foreach($activities as $activity){
  ..
}

Any idea?

thanks!

+1  A: 

Try this instead:

foreach($activities as $key => $a){
  if(...){
    unset($activitie[$key]);
  }
}
Sarfraz
although it's not technically the answer, it has inspired me to take a new approach. It seems that the sfOutputEscaperIteratorDecorator collection is read only so I can't remove elements (although it seems that its counter works in a different way). What I now do is adding the elements to a different array, and then unset() the elements I don't want. Thanks!
fesja
A: 

There's also array_splice()

Zane Edward Dockery