split ViewHelper <f:split>
¶
The SplitViewHelper splits a string by the specified separator, which results in an array. The number of values in the resulting array can be limited with the limit parameter, which results in an array where the last item contains the remaining unsplit string.
This ViewHelper mimicks PHP's explode()
function.
Examples¶
Split with a separator¶
<f:split value="1,5,8" separator="," />
Copied!
{0: '1', 1: '5', 2: '8'}
Copied!
Split using tag content as value¶
<f:split separator="-">1-5-8</f:split>
Copied!
{0: '1', 1: '5', 2: '8'}
Copied!
Split with a limit¶
<f:split value="1,5,8" separator="," limit="2" />
Copied!
{0: '1', 1: '5,8'}
Copied!
Arguments¶
value¶
- DataType
- string
- Required
- false
- Description
- The string to explode
separator¶
- DataType
- string
- Required
- true
- Description
- Separator string to explode with
limit¶
- DataType
- mixed
- Default
- 9223372036854775807
- Required
- false
- Description
- If limit is positive, a maximum of $limit items will be returned. If limit is negative, all items except for the last $limit items will be returned. 0 will be treated as 1.