Cleaner way of using modulus for columns

后端 未结 4 1896
一个人的身影
一个人的身影 2021-01-26 10:31

I currently have a list (

    ) of people that I have divided up into two columns. But after finishing the code for it I keept wondering if there is a more effective or cle
4条回答
  •  隐瞒了意图╮
    2021-01-26 11:13

    $cols = 3;
    $chunkSize = ceil(count($areaArray) / $cols);
    echo $chunkSize * $cols;
    foreach (array_chunk($areaArray, $chunkSize) as $items) : ?>
     
      

提交回复
热议问题