input|replace( offset [, length [, element1 [, element2 [, ...]]] ] )
Name | Type | Description | Required |
---|---|---|---|
offset | integer | The offset to start replacing elements. | Yes |
length | integer | The number of elements that should be replaced. | No |
element1 | any | The new element that will replace the old one. | No |
element2 | any | The new element that will replace the old one. | No |
This operator replaces elements(s) from the input array and a replaced version of input array will be returned. The "offset" parameter must be used to define the start of the portion that should be replaced. The "length" parameter can be used to define the number of elements that should be replaced. If length is omitted, the element(s) will be placed after the offset(like 'insert' operator).
Example 1
{array( 1, 2, 3, 4, 5 )|replace( 1, 2 )}
The following array will be returned: ( 1, 4, 5 ).
Example 2
{array( 1, 2, 3, 4, 5 )|replace( 3 )}
The following array will be returned: ( 1, 2, 3, 4, 5 ).
Example 3
{array( 1, 2, 3, 4, 5 )|replace( 1, 2, 'a', 'b', 'c' )}
The following array will be returned: ( 1, 'a', 'b', 'c', 4, 5 ).
Example 4
{array( 1, 2, 3, 4, 5 )|replace( 1, , 'a', 'b', 'c' )}
The following array will be returned: ( 1, 'a', 'b', 'c', 2, 3, 4, 5 ).
Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.