Arrays
| Operator | Summary |
|---|---|
| append | Returns the input array with appended elements. |
| array | Creates and returns a new array. |
| array_sum | Returns the sum of all elements in an array. |
| begins_with | Checks if an array starts with a specific element/sequence. |
| compare | Compares the contents of two arrays. |
| contains | Checks if an array contains a specific element. |
| ends_with | Checks if an array ends with a specific element or sequence. |
| explode | Splits the input array and returns it as an array of sub-arrays. |
| extract | Returns a portion of the input array. |
| extract_left | Returns a portion of the start of the input array. |
| extract_right | Returns a portion of the end of the input array. |
| hash | Creates and returns a new associative array (a hash). |
| implode | Joins array elements with strings. |
| insert | Inserts an element/sequence at specified position in an array. |
| merge | Merges input and passed arrays into one array. |
| prepend | Returns the input array prepended with specified elements. |
| remove | Returns the input array without some of the original elements. |
| repeat | Returns a repeated version of the input array. |
| reverse | Returns a reversed version of the input array. |
| unique | Returns the input array without duplicate elements. |
In this section
- append Exponential Documentation
- array Exponential Documentation
- array_sum Exponential Documentation
- begins_with Exponential Documentation
- compare Exponential Documentation
- contains Exponential Documentation
- ends_with Exponential Documentation
- explode Exponential Documentation
- extract Exponential Documentation
- extract_left Exponential Documentation
- extract_right Exponential Documentation
- hash Exponential Documentation
- implode Exponential Documentation
- insert Exponential Documentation
- merge Exponential Documentation
- prepend Exponential Documentation
- remove Exponential Documentation
- repeat Exponential Documentation
- reverse Exponential Documentation
- unique Exponential Documentation
Contributors
- Balazs Halasy Updated
- Claudia Kosny Commenter
- Kjartan Commenter
Comments (3 historical)
Written by readers of the earlier documentation sites, kept as they were.
count array elements
Claudia Kosny ·
There also a nice but undocumented count() operator.
Usage:
{def $arr = array(1,2,3,4)} {$arr|count()}sort arrays
Claudia Kosny ·
There is no sort function built in (EZ 3.8.3), but there is a nice extension which provides template operators for most PHP array sort functions here:
http://ez.no/community/contribs/template_plugins/arraysortoperator
Just for easy reference:
Kjartan ·
You can access an element in an array as follows: (Copied from "variable usage" from the manual)
{def $sentence=array( 'Life', 'is', 'very', 'good!' )}
The 1st element is: {$sentence.0} <br />
The 2nd element is: {$sentence.1} <br />
The 3rd element is: {$sentence[2]} <br />
The 4th element is: {$sentence[3]} <br />
{undef}