mercredi 2 septembre 2015

Elseif condition won't work

With "elseif" i want to check if there are more than 4 elements and than give all the elements the class of "col-md-5ones" but nothing happens.

if(sizeof($elements)>0) {
    $size = ceil(12 / sizeof($elements));
    foreach($elements AS $element) {
         echo '<article class="col-md-'.$size.'">'.$element.'</article>';
    }
} 

elseif(sizeof($elements)==5) {
    foreach($elements AS $element) {
        echo '<article class="col-md-5ones">'.$element.'</article>';
    }
}

This shows me the correct count of elements:

echo sizeof($elements);

So i don't understand why i can't do a elseif condition here?

Aucun commentaire:

Enregistrer un commentaire