function drupal_map_assoc

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

38 calls to drupal_map_assoc()
aggregator_block_configure in drupal/modules/aggregator/aggregator.module
Implements hook_block_configure().
aggregator_form_aggregator_admin_form_alter in drupal/modules/aggregator/
Implements hook_form_aggregator_admin_form_alter().
aggregator_form_feed in drupal/modules/aggregator/
Form constructor for adding and editing feed sources.
aggregator_form_opml in drupal/modules/aggregator/
Form constructor for importing feeds from OPML.
blog_block_configure in drupal/modules/blog/blog.module
Implements hook_block_configure().

... See full list


drupal/includes/, line 2828
Common functions that many Drupal modules will need to reference.


function drupal_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;