如何在foreach循环中每5次迭代后定义html标签
本文介绍了如何在foreach循环中每5次迭代后定义html标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想知道如何在 foreach 循环中每 5 次迭代后定义 HTML 标签 <br clear="all">
这是我的代码
I just want to know how to define HTML Tag <br clear="all">
after each 5 iteration in foreach loop here is my code
<?php
$i=1;
foreach($videoEntries as $data){
?>
<div class="item-main">
<div class="item">
<a href="javascript:;" onclick="ratePopup(2)" title="<?php echo $data->video_name;?>">
<div class="overlaid"></div>
<img src="<?php echo $image_url;?>" width="93" height="89"/>
</a>
</div>
<p title="Trailer Name"><strong><?php echo $data->video_name;?></strong></p>
<p title="Released Date"><?php echo $data->video_released_date;?></p>
</div>
<?php
if($i == 5){
echo "<br clear = 'all'>";
}
}
?>
结果需要或帮助肯定是appricicated
Result Required or helps are definitely appricicated
12345
<br clear="all">
678910
<br clear="all">
推荐答案
试试这个:
<?php
$i=0;
foreach($videoEntries as $data){
$i++;
?>
<div class="item-main">
<div class="item">
<a href="javascript:;" onclick="ratePopup(2)" title="<?php echo $data->video_name;?>">
<div class="overlaid"></div>
<img src="<?php echo $image_url;?>" width="93" height="89"/>
</a>
</div>
<p title="Trailer Name"><strong><?php echo $data->video_name;?></strong></p>
<p title="Released Date"><?php echo $data->video_released_date;?></p>
</div>
<?php
if($i == 5){
echo "<br clear = 'all'>";
$i=0;
}
}
?>
这篇关于如何在foreach循环中每5次迭代后定义html标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!