php中的smarty如何循环添加数据

来源:百度知道 编辑:UC知道 时间:2024/09/26 04:22:52
A:<input type="text_subject_1" value="{$item.option_A}">
B:<input type="text_subject_2" value="{$item.option_B}">
C:<input type="text_subject_3" value="{$item.option_C}">
这个是我写死的一段程序 能不能用循环写出来啊 里面的A,B,C,1,2,3我想用变量来代替,但是我写不来,请高手帮助
1楼的答案并不是我想要的结果,还有没有其他的答案啊??? 急

给TPL一个数组,然后循环输出就好了,下面是手册上的例子
{* this example will print out all the values of the $custid array *}
{foreach from=$custid item=curr_id}
id: {$curr_id}<br>
{/foreach}

OUTPUT:

id: 1000<br>
id: 1001<br>
id: 1002<br>