How to write the formula for output of elements on the screen?

Good afternoon.

I have a floor problem decided, there is to add automation.

There is a container in which there is an inexhaustible number of elements.

In the same row are placed 3.

For the first number specifies the class of 'fadeInRight', for second 'fadeInLeft' and then for the 3rd row again, 'fadeInRight'.

No wrappers for series do not need to create as container set a property grid.

Here's how I managed to solve this problem

<div class="auto">
 <?php $i = 1; while($auto->have_posts()): ?>
 $content = get_the_content();

 <div class="auto__wow item <?php echo (( $i > 0 && $i < 4 ) || ($i > 6 && $i < 10) || ($i > 12 && $i < 16)) ? 'fadeInLeft' : 'fadeInRight'; ?>">
 <?php the_post_thumbnail('full'); ?>
 <h3><?php the_title(); ?></h3>
 <p><?php echo wp_trim_words($content); ?></p>
 <a href="<?php the_permalink(); ?>" class="btn">Read more</a>

 <?php $i++; endwhile; ?>

It is clear that I can't calculate and to register ( $i > 0 && $i < 4 )

The pattern is one that i is a multiple of 6.

I'm not so good at math.
The project test, I saw the plugin isotope jquery, and wanted to apply, but faced with this problem

In advance I will be grateful for the tip.
March 23rd 20 at 19:10
2 answers
March 23rd 20 at 19:12
<?php echo ( $i % 6 > 0 && $i % 6 < 4 ) ? 'fadeInLeft' : 'fadeInRight'; ?>
Thank you, it works.

It turns out, that simple. - emmitt_Nicola commented on March 23rd 20 at 19:15
March 23rd 20 at 19:14
For magnification there is such a thing as a remainder or modulus. Read more here. Conditional test if ( $var % 6 ) returns 0 if $var is divisible by 6 without remainder (that is, multiples of 6). All this is in the PHP documentation in the section about arithmetic operators.
This is only part of the answer.
About division with remainders, I knew just then need to come up with another formula, where it will be calculated at each iteration of the loop, the value of the right and left of the sign && in this expression, ( $i > 0 && $i < 4 )

I'm a little busy, but then must decide.

Thanks for the answer. - emmitt_Nicola commented on March 23rd 20 at 19:17

Find more questions by tags PHP