PHP while loop ODD and Even wrapped in either the left or right column
<p>I cant seem to get this right, basically I have a while loop and i want all odd posts to get wrapped in a div called .split-left, so 1,3,5 etc will go into that column. Then all EVEN posts must go into .split-right div so 2, 4, 6 etc.</p>

<p>Currently my loop is putting post 1 into the .split-left div but then its putting 2, 4, 6 into the split-left div as well, something is not right.</p>

<pre><code>&lt;!-- SPLIT EFFECT PAGE BUILDER --&gt;
&lt;div class="page-builder split"&gt;

&lt;?php if( have_rows('split_effect_page_builder') ): ?&gt;
  &lt;div class="split-left"&gt;
  &lt;?php $i = 1; ?&gt;
  &lt;?php while ( have_rows('split_effect_page_builder') ) : the_row(); ?&gt;

    &lt;?php get_template_part('template-parts/page', 'builder'); ?&gt;

    &lt;?php
      if($i % 2 == 0){
        echo '&lt;/div&gt;&lt;div class="split-right"&gt;';
        $i = 0;
      } 
      $i++; 
    ?&gt;

  &lt;?php endwhile; ?&gt;
  &lt;/div&gt;
&lt;?php else : ?&gt;

&lt;?php // no layouts found ?&gt;

&lt;?php endif; ?&gt;
&lt;/div&gt;
&lt;!-- END SPLIT EFFECT PAGE BUILDER --&gt;
</code></pre>

<p>This part below is just a template with the loop, so just think of this as a normal PHP while loop.</p>

<pre><code>&lt;?php get_template_part('template-parts/page', 'builder'); ?&gt;
</code></pre>

<p>Nobody seems to be able to help me with this, i have googled and checked everywhere for some code that splits even and odd posts into two columns, but have found nothing to even reference to help me out to fix this.</p>