Answer the question
In order to leave comments, you need to log in
How to display information in four columns?
In the footer, you need to display 3 columns footer-top__list with four li. I tried to do it like this, but for some reason each li is wrapped in footer-top_list. What's wrong? Please help to implement menu display in three columns.
<?$d = ceil(count($arResult["TEXT"])/3);
$i = 0;
?><ul class="footer-top__list"><?
foreach($arResult as $arItem)
{
if( $i > 0 && $i%$d == 0) {?></ul><ul class="footer-top__list"><?}
?><li><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></li><?
$i++;
}
?></ul><? ?>
Answer the question
In order to leave comments, you need to log in
Try
<? $n = count($arResult["TEXT"]);
$d = ceil($n / 4);
$n--;
$i = 0; ?>
<ul class="footer-top__list">
<? foreach($arResult as $arItem) { ?>
<li><a href="<?= $arItem["LINK"] ?>"><?= $arItem["TEXT"] ?></a></li>
<? if( $i%$d == 0 && $i > 0 && $i < $n) {?>
</ul><ul class="footer-top__list">
<?}
$i++;
} ?>
</ul>
<?$d = ceil(count($arResult["TEXT"])/3);
$i = 0;
?><ul class="footer-top__list"><?
foreach($arResult as $arItem)
{
?><li><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></li><?
$i++;
}
?></ul><? ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question