Skip to the content
Documentation

count

No ratings yet

Summary

Returns the count of the input parameter.

Usage

input|count()

Returns

An integer revealing the count.

Description

This operator returns the count of the input parameter. The following table shows how the operator works with different variable types.

Type Description
Array The number of elements is returned.
Object The number of object attributes is returned.
String The length of the string is returned.
Number The value itself is returned.
Boolean FALSE results in 0 and TRUE results in 1.
Other 0 is returned.

Examples

Example 1
{array( 1, 2, 5 )|count()}

The following output will be produced: "3".

Contributors

Comments (1 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. Input string as argument

    Meinhard Benn ·

    You can also get a string length with count():

    {count('hello world')}

Comments

Add a comment

Comments are read by a moderator before they appear.