Home >php教程 >php手册 >php中smarty区域循环的方法

php中smarty区域循环的方法

WBOY
WBOYOriginal
2016-06-06 20:03:391506browse

这篇文章主要介绍了php中smarty区域循环的方法,实例分析了smarty中foreach循环与section循环的使用技巧,需要的朋友可以参考下

本文实例讲述了php中smarty区域循环的方法。分享给大家供大家参考。具体实现方法如下:

Smarty Test {foreach key=key1 item=item1 from=$array1} {/foreach}
{$key1} {$item1}

"Simon", 2 => "Elaine", 3 => "Susan"); //定义数组 $smarty->assign("array1",$array1); //对模版中的变量赋值 $smarty->display('test3.htm'); //显示页面 ?>

另一种方法:

Smarty Test {section name=section1 loop=$array1} {/section}
{$array1[section1]}

"Simon", 1 => "Elaine", 2 => "Susan"); //定义数组 $smarty->assign("array1",$array1); //对模版中的变量赋值 $smarty->display('test10.htm'); //显示页面 ?>

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn