contains
Summary
Checks if an array contains a specific element.
Usage
input|contains( element )
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| element | any | The element that should be matched. | Yes. |
Returns
TRUE if the element is found, FALSE if not.
Description
This operator checks if the input array contains a specific element (specified using the first parameter). If it does, the operator will return TRUE, otherwise FALSE will be returned.
Examples
Example 1
{array( 1, 2, 3, 4, 5 )|contains( 3 )}Returns TRUE.
Example 2
{array( 1, array( 3, 4 ), 5 )|contains( array( 3, 4 ) )}Returns TRUE.
Example 3
{array( 1, array( 3, 4 ), 5 )|contains( 3 )}Returns FALSE.
Contributors
- Balazs Halasy Updated
- Richard Tuin Commenter
Comments (1 historical)
Written by readers of the earlier documentation sites, kept as they were.
Recursively?
Richard Tuin ·
In example 3 is told recursive searching through arrays is not possible.
Is this going to be supported in some way?
In my specific situation it comes very handy when checking the validation array which comes involved with form processing.