WordPress at a glance
function is not described


DataStore::map_array_by_key() protected WC 1.0

Returns the same array index by a given key

{} It's a method of the class: DataStore{}

No Hooks.


Array. Nothing.


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

Code of DataStore::map_array_by_key() WC 5.3.0

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