Get size of an array in Volt

Kvothe picture Kvothe · Aug 11, 2015 · Viewed 7.3k times · Source

In Volt (the template engine for Phalcon) how can I get the number of elements in an array? I've tried sizeof and also count, length and size (hoping to stumble upon the correct command).

In this particular instance I'm just interested in whether there are >0 elements but in the future it would be handy to be able to get the actual number.

Answer

Raj picture Raj · Aug 12, 2015

Length: Counts the string length or how many items are in an array or object

MoreInfo: https://docs.phalconphp.com/en/latest/reference/volt.html#filters

{{ yourarray_Var|length }}