As the title says: I have a foreach loop but every third time the loop will pass it must do something else. How to do this? Thanks in advance. I tried:
$count = 0
foreach ($cObjects as $oObject) {
if ($count <= 2) {
//do things
$count = 0;
} else {
// do other things
}
$count++;
}
This didn't work ofcourse, while it resets the count everytime to 0.
Replacing if($count <= 2)
to if($count == 2)
works.