有人可以将此代码转换为纯PHP。
{assign var="counter" value="0"}
{$counter=0}
{foreach from=$entries item=entry}
{math equation="x + 1" x=$counter assign="counter"}
<div class="entry">...</div>
{if $counter==6}
<div class="content">...</div>
{/if}
{/foreach}
非常感谢,抱歉我的文盲。
编辑: $ counter计算列出了多少条目(在这种情况下来自数据库的图像),并且在一定数量之后它显示一些外部内容(例如:广告),然后条目继续从它们离开的位置列出。
答案 0 :(得分:0)
$counter = 1;
foreach ($entries as $entry) {
echo '<div class="entry">...</div>';
// If the counter value is divisible by 6, then output the extra content.
// Increment the counter afterwards
if ($counter++ % 6 == 0) {
echo '<div class="content">...</div>';
}
}
你想要实现的目标并不是很清楚,所以我对此有了解释。