PHP 配列から 2 つの順序付けられていないリストを作成しようとしています。探しているものとほぼ同じこのスレッドを見つけましたが、最初のリストには 11 個の項目があり、2 番目のリストには残りの項目が必要です。これが私のコードです:
<?php if ($rows) :
$items = count($rows);
$split = ceil($items/2);
$firsthalf = array_slice($rows,$split);
$secondhalf = array_slice($rows,0,$split);
?>
<div class="tickets">
<div class="col1">
<ul>
<?php foreach ($firsthalf as $item) : ?>
<li><a href="">test 1</a></li>
<?php endforeach; ?>
</ul>
</div>
<div class="col2">
<ul>
<?php foreach ($secondhalf as $item) : ?>
<li><a href="">test 2</a></li>
<?php endforeach; ?>
</ul>
</div>
<div class="clear"></div>
</div>
<?php endif; ?>