A very simple yet maybe not obvious use of the modulus (%) operator is to check if an integer is odd or even.
<?php
if (($a % 2) == 1)
{ echo "$a is odd." ;}
if (($a % 2) == 0)
{ echo "$a is even." ;}
?>
This is nice when you want to make alternating-color rows on a table, or divs.
<?php
for ($i = 1; $i <= 10; $i++) {
if(($i % 2) == 1) //odd
{echo "<div class=\"dark\">$i</div>";}
else //even
{echo "<div class=\"light\">$i</div>";}
}
?>