WireArray::explode() method

Return a plain array of the requested property from each item

You may provide an array of properties as the $property, in which case it will return an array of associative arrays with all requested properties for each item.

You may also provide a function as the $property. That function receives the $item as the first argument and $key as the second. It should return the value that will be stored.

The keys of the returned array remain consistent with the original WireArray.

Usage

// basic usage
$array = $wireArray->explode();

// usage with all arguments
$array = $wireArray->explode($property = '', array $options = []);

Arguments

NameType(s)Description
property (optional)string, callable, array

Property or properties to retrieve, or callable function that should receive items.

options (optional)array

Options to modify default behavior:

  • getMethod (string): Method to call on each item to retrieve $property (default = "get")
  • key (string|null): Property of Wire objects to use for key of array, or omit (null) for non-associative array (default).

Return value

array

See Also


WireArray methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #554
    In the 554th issue of ProcessWire Weekly we'll check out the latest core updates, introduce a couple of new third party modules, and more. Read on!
    Weekly.pw / 21 December 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK