jun
Новичок
Здравствуйте! Я начал недавно изучать PHP, столкнулся с первой сложностью, как вывести html в цикле средствами php? Вот по такой структуре:
Т-е один <div class="block_thee"> в нем 4 div и тд
Вот что сделал:
PHP:
<div class="block_thee">
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
</div>
<div class="block_thee">
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
</div>
<div class="block_thee">
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
<div>$row['text'][i]</div>
</div>
Вот что сделал:
PHP:
while () {
$s .= !($i % 3) ? '<div class="block_thee">' : "";
$s .= '<div><a data-fancybox-group="gallery" rel="example_group" class="plus" href="'.$matches[2][0].'"><img width="196" height="99" title="'.$row['title'].'" src="'.$matches[2][0].'" alt="'.$row['title'].'"></a></div>';
$s .= !(($i+1) % $links_count) ? "</div>" : "";
$i++;
}
echo $s;