Search code examples
arraysphalconvolt

Get size of an array in Volt


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.


Solution

  • 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 }}