Automattic\WooCommerce\Admin\API\Reports\Orders

DataStore::map_array_by_key()protectedWC 1.0

Returns the same array index by a given key

Method of the class: DataStore{}

No Hooks.

Return

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() code WC 8.6.1

protected function map_array_by_key( $array, $key ) {
	$mapped = array();
	foreach ( $array as $item ) {
		$mapped[ $item[ $key ] ] = $item;
	}
	return $mapped;
}