Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

count

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".

Balazs Halasy (05/02/2004 10:45 am)

Balazs Halasy (06/05/2005 7:16 am)


Comments

  • Input string as argument

    You can also get a string length with count():
    {count('hello world')}