Arrays smarty中的处理阵列
我正在尝试使用section命令访问smarty中的阵列。我想在smarty中使用section命令迭代1-128,但主要的是循环必须是65。现在,我可以使用$smarty.section.foo.index访问多达64个索引。我想使用一个常量{$lan.printer[$smarty.section.foo.index]+64}访问index>64中的值。但它不起作用。请帮我解决这个问题 我的代码如下Arrays smarty中的处理阵列,arrays,loops,smarty,Arrays,Loops,Smarty,我正在尝试使用section命令访问smarty中的阵列。我想在smarty中使用section命令迭代1-128,但主要的是循环必须是65。现在,我可以使用$smarty.section.foo.index访问多达64个索引。我想使用一个常量{$lan.printer[$smarty.section.foo.index]+64}访问index>64中的值。但它不起作用。请帮我解决这个问题 我的代码如下 {section name=foo start=1 loop=65 step=1}
{section name=foo start=1 loop=65 step=1}
{$lan.printer[$smarty.section.foo.index]}
{$lan.printer[$smarty.section.foo.index]+64}
{/section}
提前感谢。除了代码中明显的打字错误之外,要使用表达式作为数组的索引,您需要首先将其分配给变量,以便可以引用它:
{section name=foo start=1 loop=65 step=1}
{assign var=offsetIndex value=$smarty.section.foo.index+64}
{$lan.printer[$smarty.section.foo.index]}
{$lan.printer[$offsetIndex]}
{/section}