Hi, I have a loop which creates 4 div's in a rows. Now i like to add a different class to the first and fourth div in a row <div class="grid_4 alpha center"> <div class="grid_4 center"> <div class="grid_4 center"> <div class="grid_4 omega center"> PHP: Should i use modulus, if so how ??
if your divs are static to 4 counts you can just use the condition for($i=1,$n=4; $i<=$n; $i++) { $addedString = $i=1 || $i=$n ? 'add your string here' : ''; echo '<div class="grid_4 alpha center" '. $addedString .'>'; }
nice suggestion, going to try it out. but i need two different classes i have found this to work also ok found it $extraclass = $i % 4; if($extraclass==0) $extraclass = 'alpha'; elseif($extraclass==3) $extraclass = 'omega'; else $extraclass = ''; $output .= "<div class='grid_4 $extraclass center'> Code (markup):