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.

explode

Summary

Splits the input string and returns it as an array of strings.

Usage

input|explode( separator )

Parameters

NameTypeDescriptionRequired
separator string Split sequence. Yes.

Returns

An array of strings.

Description

This operator takes a string as input and returns an array of strings. Each element in the array will be a part of the input string extracted on the basis of the specified sequence of split characters.

Examples

Example 1

{'All-your-base-are-belong-to-us!'|explode( '-' )}

The following array will be returned: ( 'All', 'your', 'base', 'are', 'belong', 'to', 'us!' ).

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

Balazs Halasy (04/05/2005 2:40 pm)


Comments

  • Explode/Implode as string replacement

    If you're in a pinch, you can pair explode and implode to do very basic string replacement:

    {def $x="My-Dog-Has-Fleas"}
    {def $y=$x|explode('-')|implode(' ')}
    {$y}
    


    will print "My Dog Has Fleas"