function drupal_map_assoc

cis7 common.inc drupal_map_assoc($array, $function = NULL)
cle7 common.inc drupal_map_assoc($array, $function = NULL)
elmsmedia7 common.inc drupal_map_assoc($array, $function = NULL)
icor7 common.inc drupal_map_assoc($array, $function = NULL)
meedjum_blog7 common.inc drupal_map_assoc($array, $function = NULL)
mooc7 common.inc drupal_map_assoc($array, $function = NULL)

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.

Parameters

$array: A linear array.

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

Return value

An associative array.

109 calls to drupal_map_assoc()
advanced_help_form_system_modules_alter in sites/all/modules/ulmus/advanced_help/advanced_help.module
Implements hook_form_system_modules_alter().
aggregator_block_configure in modules/aggregator/aggregator.module
Implements hook_block_configure().
aggregator_form_aggregator_admin_form_alter in modules/aggregator/aggregator.processor.inc
Implements hook_form_aggregator_admin_form_alter().
aggregator_form_feed in modules/aggregator/aggregator.admin.inc
Form constructor for adding and editing feed sources.
aggregator_form_opml in modules/aggregator/aggregator.admin.inc
Form constructor for importing feeds from OPML.

... See full list

File

includes/common.inc, line 2748
Common functions that many Drupal modules will need to reference.

Code

function drupal_map_assoc($array, $function = NULL) {
  // array_combine() fails with empty arrays:
  // http://bugs.php.net/bug.php?id=34857.
  $array = !empty($array) ? array_combine($array, $array) : array();
  if (is_callable($function)) {
    $array = array_map($function, $array);
  }
  return $array;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.