Automattic\WooCommerce\Admin\API\Reports\Orders
DataStore::map_array_by_key
Returns the same array index by a given key
Method of the class: DataStore{}
No Hooks.
Returns
array.
Usage
// protected - for code of main (parent) or child class $result = $this->map_array_by_key( $array, $key );
- $array(array) (required)
- Array to be looped over.
- $key(string) (required)
- Key of values used for new array.
DataStore::map_array_by_key() DataStore::map array by key code WC 11.0.1
protected function map_array_by_key( $array, $key ) {
$mapped = array();
foreach ( $array as $item ) {
$mapped[ $item[ $key ] ] = $item;
}
return $mapped;
}