drupal_map_assoc

Versions
4.6 – 7
drupal_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.

@result An associative array.

Parameters

$array A linear array.

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

▾ 25 functions call drupal_map_assoc()

aggregator_admin_settings in modules/aggregator/aggregator.admin.inc
Form builder; Configure the aggregator system.
aggregator_block in modules/aggregator/aggregator.module
Implementation of hook_block().
aggregator_form_feed in modules/aggregator/aggregator.admin.inc
Form builder; Generate a form to add/edit feed sources.
contact_admin_settings in modules/contact/contact.admin.inc
dblog_admin_settings in modules/dblog/dblog.admin.inc
dblog module settings form.
expand_date in includes/form.inc
Roll out a single date element.
form_type_select_value in includes/form.inc
Helper function to determine the value for a select form element.
forum_admin_settings in modules/forum/forum.admin.inc
Form builder for the forum settings page.
forum_block in modules/forum/forum.module
Implementation of hook_block().
hook_search in developer/hooks/core.php
Define a custom search routine.
node_configure in modules/node/node.admin.inc
Menu callback; presents general node configuration options.
node_search in modules/node/node.module
Implementation of hook_search().
node_type_form in modules/node/content_types.inc
Generates the node type editing form.
poll_form in modules/poll/poll.module
Implementation of hook_form().
search_admin_settings in modules/search/search.admin.inc
Menu callback; displays the search module settings page.
statistics_access_logging_settings in modules/statistics/statistics.admin.inc
Form builder; Configure access logging.
statistics_block in modules/statistics/statistics.module
Implementation of hook_block().
system_performance_settings in modules/system/system.admin.inc
Form builder; Configure site performance settings.
system_rss_feeds_settings in modules/system/system.admin.inc
Form builder; Configure how the site handles RSS feeds.
system_themes_form in modules/system/system.admin.inc
Menu callback; displays a listing of all themes.
taxonomy_form_term in modules/taxonomy/taxonomy.admin.inc
Form function for the term edit form.
update_script_selection_form in ./update.php
user_block in modules/user/user.module
Implementation of hook_block().
_comment_per_page in modules/comment/comment.module
Return an array of "comments per page" settings from which the user can choose.
_filter_htmlcorrector in modules/filter/filter.module
Scan input and make sure that all HTML tags are properly closed and nested.

Code

includes/common.inc, line 1633

<?php
function drupal_map_assoc($array, $function = NULL) {
  if (!isset($function)) {
    $result = array();
    foreach ($array as $value) {
      $result[$value] = $value;
    }
    return $result;
  }
  elseif (function_exists($function)) {
    $result = array();
    foreach ($array as $value) {
      $result[$value] = $function($value);
    }
    return $result;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.