This is the old documentation center for eZ Publish 4. We are currently migrating the eZ Publish documentation to http://confluence.ez.no the eZ Publish 5 documentation platform. Documentation for the eZ Publish legacy components are still located on this site, as well as all documentation for earlier releases.

replace

Summary

Replaces elements in an array.

Usage

input|replace( offset [, length [, element1 [, element2 [, ...]]] ] )

Parameters

NameTypeDescriptionRequired
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

Returns

A replaced version of the input array.

Description

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

Examples

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

Geir Arne Waaler (19/08/2010 11:14 am)

Geir Arne Waaler (19/08/2010 11:45 am)


Comments

There are no comments.