explode
Summary
Splits the input array and returns it as an array of sub-arrays.Usage
input|explode( offset )
Parameters
Name | Type | Description | Required |
---|---|---|---|
offset | integer | The offset where the array should be split. | Yes. |
Returns
An array containing the original array as two arrays.Description
This operator splits the input array at an offset specified by the "offset" parameter. The operator will return an array containing the two arrays.
Examples
Example 1
{array( 1, 2, 3, 4, 5 )|explode( 3 )}
The following array will be returned: ( ( 1, 2, 3 ), ( 4, 5 ) ).
Balazs Halasy (05/02/2004 9:31 am)
Balazs Halasy (04/05/2005 1:29 pm)
Comments
Documentation incomplete
Monday 15 September 2008 3:47:57 pm
Massimo Sanna
this is just a part of how explode works (and actually the more bizarre).
The docs don't state it also works as a normal PHP explode, this is the actual code from eZ Publish:
Therefore if we have a string we can do the following: {$myString|explode("\n")} and we'll get an array split by the parameter I wrote in the string.
...and if we use implode subsequently we can obtain a string with the spaces replaced for example, without having to install the ezstr_replace extension (which is not supported on ez4).
Max
Re: Documentation incomplete
Monday 15 September 2008 4:26:17 pm
Svitlana Shatokhina