function drush_map_assoc

8.0.x drush_map_assoc($array, $function = NULL)
6.x drush_map_assoc($array, $function = NULL)
7.x drush_map_assoc($array, $function = NULL)
5.x drush_map_assoc($array, $function = NULL)
master drush_map_assoc($array, $function = NULL)

Form an associative array from a linear array.

This function walks through the provided array and constructs an associative array out of it. The keys of the resulting array will be the values of the input array. The values will be the same as the keys unless a function is specified, in which case the output of the function is used for the values instead.


$array: A linear array.

$function: A name of a function to apply to all values before output.

Return value

An associative array.

3 calls to drush_map_assoc()
drush_config_export in commands/core/
Command callback: Export config to specified directory (usually sync).
drush_config_import in commands/core/
Command callback. Import from specified config directory (defaults to sync).
drush_core_config in commands/core/
Command callback. Edit drushrc and alias files.


includes/, line 1753
The drush API implementation and helpers.


function drush_map_assoc($array, $function = NULL) {
  // array_combine() fails with empty arrays:
  $array = !empty($array) ? array_combine($array, $array) : array();
  if (is_callable($function)) {
    $array = array_map($function, $array);
  return $array;