0 | 1 | 2 |
3 | 4 | 5 |
6 | 7 | 8 |
0 | 0 | 0 |
1 | 1 | 1 |
2 | 2 | 2 |
<table class="table table-bordered field-items"<?php print $content_attributes; ?>>
<?php foreach ($items as $delta => $item): ?>
<tr>
<?php for($i=0; $i <= 2; $i++): ?>
<td>
<?php print render($item); ?>
</td>
<?php endfor; ?>
</tr>
<?php endforeach; ?>
</table>
$items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
$rows = array_chunk($items, 3);
foreach ($rows as $items) {
foreach ($items as $item) {
echo $item;
}
}
<?php
$data = [
0 => [
0,
1,
2,
],
1 => [
3,
4,
5,
],
2 => [
6,
7,
8,
],
];
?>
<table>
<?php $count1 = count($data); ?>
<?php for ($i = 0; $i < $count1; $i++) { ?>
<tr>
<?php $count2 = count($data[$i]); ?>
<?php for ($j = 0; $j < $count2; $j++) { ?>
<td><?= $data[$i][$j] ?></td>
<?php } ?>
</tr>
<?php } ?>
</table>