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.244

Latest news

  • ProcessWire Weekly #559
    The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 25 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits