title: PHP loop: Add a div around every three items syntax
body: <p>I'm using a loop in wordpress to output posts. I want to wrap every three posts inside of a div. I want to use a counter to increment on each iteration of the loop but I'm not sure of the syntax that says "if $i is a multiple of 3" or "if $i is a multiple of 3 - 1".</p>
  
  <pre><code>$i = 1;
  if ( $wp_query-&gt;have_posts() ) : while ( $wp_query-&gt;have_posts() ) : $wp_query-&gt;the_post();
       // If is the first post, third post etc.
       if("$i is a multiple of 3-1") {echo '&lt;div&gt;';}
  
       // post stuff...
  
       // if is the 3rd post, 6th post etc
       if("$i is a multiple of 3") {echo '&lt;/div&gt;';}
  
  $i++; endwhile; endif;
  </code></pre>
  
  <p>How do I make this happen? thanks!</p>