Different css styling for last element of a php array

前端 未结 3 1578
遥遥无期
遥遥无期 2021-01-22 13:41

When looping through an array how can I create a different css div style for the last element to be output in my array.

for($i=0;$i<=count($productid);$i++){         


        
3条回答
  •  情话喂你
    2021-01-22 14:30

    Like this:

    if($productid[$i] ==  $productid[count($productid)-1]){
        //last element code here
    } elseif (($productid[$i] % 2 ){
       //even row code here
    } else {
       //odd row code here
    }
    

提交回复
热议问题