Thursday, 12 September 2013

How to add css class in foreach loop with some condition

How to add css class in foreach loop with some condition

I have this loop in my code:
$results = modleftHelper::getNear();
$i = 0;
foreach($results as $result){
echo '<div class="filter-div" data-filter="'.$result->near.'">';
echo '<label id="lbl_type'.$i.'" class="label_check" name="near"
style="width:230px !important;">';
echo '<input name="school[]" class="chkBX"
value="'.$result->latitude.','.$result->longitude.'"
type="checkbox" />'.$result->school.'</label>';
echo '</div>';
$i++;
}
I want to add clear class every 3, 6, 9 etc in this div:
<div class="filter-div" data-filter="'.$result->near.'">';
Any ideas or suggestions? Thanks.

No comments:

Post a Comment