25

How can I get the total number of items in an array using Smarty? Can I use {$smarty.foreach.foo.total}?

conbask
  • 9,741
  • 16
  • 57
  • 94

1 Answers1

59

This question is answered on Smarty's FAQ page: http://smarty.incutio.com/?page=SmartyFrequentlyAskedQuestions#template-1

Q: How do I count the number of elements in an array?
A: {$array|@count}

The @ applies the modifier directly to the array instead of each individual element.

Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313
David
  • 786
  • 6
  • 2