douxu5233 2014-07-03 05:09
浏览 27
已采纳

PHP:如何使用smarty部分进行以下输出?

I am using the even and odd logic for that but not getting the output as i need

for example i have array of

$data = array(1000,1001,1002, 1003,1004,1005);
$smarty->assign('data',$data);

{section name=i loop=$data}

{section}

so the output i need is :

<div>
    <dl>1000</dl>
    <dl>1001</dl>
</div>

<div>
    <dl>1002</dl>
    <dl>1003</dl>
</div>

<div>
    <dl>1004</dl>
    <dl>1005</dl>
</div>
  • 写回答

2条回答 默认 最新

  • dousao6260 2014-07-03 06:00
    关注

    According to offical document http://www.smarty.net/docsv2/en/language.function.section.tpl

    Try following codes:

    <div>
    {section name=i loop=$data}
    
           <dl>{$data[i]}</dl>
    
       {if $smarty.section.data.index > 0 && $smarty.section.data.index % 2 == 0 && $smarty.section.data.index < $smarty.section.customer.total -1}
          </div><div>
       {/if}
    
    {/section}
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码