Split a string into an array, using PHP's explode function.
- Service:
CleverAge\ProcessBundle\Transformer\String\ExplodeTransformer - Transformer code:
explode
string, or a scalar or a \Stringable cast to a string. null gives null. An array or another object (a
\BackedEnum included) throws an UnexpectedValueException.
array: the list of parts; an empty array for an empty stringnullif the input isnull
| Code | Type | Required | Default | Description |
|---|---|---|---|---|
delimiter |
string |
X | The boundary string, must not be empty (checked with the configuration) |
'a,b,c'becomes['a', 'b', 'c']
# Transformer options level
explode:
delimiter: ','- Split then trim each part:
'a, b ,c'becomes['a', 'b', 'c']
# Transformer mapping level
tags:
code: '[tags]'
transformers:
explode:
delimiter: ','
array_map:
transformers:
trim: ~