Eno\ListElement » items
items() → array
items($options) → array
items($loader) → array
items($loader, $options) → array
Retrieve the items of the list, optionally passing them through a loader function.
enocolors:
- pink
- peach
php$list = Parser::parse($input)->element('colors');
$list->items(); // returns ['pink', 'peach']
$list->items(function($value) { return "{$value}!!"; }); // returns ['pink!!', 'peach!!']
Parameters
$loaderA function returning the transformed/validated value or throwing an error.
(The function is applied to each list item on its own and its argument signature
is dynamic, you can either use ($value) or ($name, $value))
elements
Whether to return the elements (as Field) instead of the values of the list items. (defaults to false)
enforce_values
Whether empty list items (- in the document, mapping to null) are disallowed (defaults to true)
with_elements
Whether to return an array of arrays of the form [ 'element' => ..., 'value' => ... ] instead of just the values (defaults to false)
Return value
The (optionally transformed/validated) items of this list as an array.