Use the modulus operator. I see @Alex has beaten me to the mark with this, but I offer this code I wrote and tested, so that others can see more clearly the principle:
$blogusers=array('a','b','c','d','e','f','g','h','i','j');
$i=0;
foreach ($blogusers as $bloguser) {
if($i % 4 === 0) $extraclass= "fourthClass";
$resultHTML .= "$bloguser
";
$i++;
$extraclass="";
}
echo $resultHTML;
Could be made more compact with the ternary operator, but this is the principle.