statmentI am currently working on a project. I am having issues with making a variable ++ in the loop while nested in if statements. I really do not understand why it's doing what it's doing. Here is my code.

```
                    <?php $i=0;
                     while ($loop->have_posts() ) : $loop->the_post(); ?>
                        <?php if(get_field('featured_game') && valid_release(get_field('release_date'))):?>
                     <div class="item <?php if($i == 0){echo 'active';}?> row carousel-<?=$i;?>">

                          // do generated html

                            <style>
                                .carousel-<?=$i;?>{
                                    // do generated css
                                }
                           </style>

                     </div>
                            <?php $i++;?>

                        <?php endif?>
                    <?php endwhile;?>
                </div>

```

My results have 
carousel-
 these spots all having returned 0 despite the loop running. meaning that incrment is not happening.

if I remove the if statement the loop works, as expected. The if statement are just to verify criteria to be true. I do can place the ++ outside of the if statement I get the same results.

Could some please explain what I am missing here? This seems like such a basic problem. I really do not understand why $i will not increment when does meet the criteria and posts the correct info. Thanks in advance to anyone who takes the effort.