【问题标题】:Length of multidimensional array with smartysmarty的多维数组的长度
【发布时间】:2013-10-10 13:02:06
【问题描述】:

我想知道smarty中多维数组的长度。

我有:{foreach itme=$i from=$var}{/foreach} 我尝试使用{$var.$id|@count} 但不工作。 我怎样才能在{for} cicle 中使用这个长度?

【问题讨论】:

  • 你的问题解决了吗?

标签: count smarty variable-length


【解决方案1】:

你的逻辑很好。您在 foreach 循环中使用 @count 是正确的。但是您的代码包含一些错误。

{foreach itme=$i from=$var}{/foreach}
       // ^----- should be item, $i should be just i without $ symbol in front 

{$var.$id|@count}
     // ^-------- this should be just $i according to your foreach loop and without $var.

所以功能代码应该是:

{foreach item=id from=$var}
    {$id|count}
{/foreach}

请注意,在 Smarty 3 中,您不必在计数修饰符前添加 @ 符号。它只是被忽略了。

【讨论】:

    猜你喜欢
    • 2011-03-11
    • 2012-01-14
    • 2023-02-25
    • 2012-07-26
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 2011-11-20
    • 2013-08-21
    相关资源
    最近更新 更多