drupal_map_assoc

  1. drupal
    1. 5
    2. 6
    3. 7
    4. 8
Versions
5 – 8 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.

Parameters

$array A linear array.

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

Return value

An associative array.

▾ 43 functions call drupal_map_assoc()

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 builder; Generate a form to add/edit feed sources.
aggregator_form_opml in modules/aggregator/aggregator.admin.inc
Form builder; Generate a form to import feeds from OPML.
ajax_example_advanced_commands in examples/ajax_example/ajax_example_advanced.inc
Form to display the AJAX Commands.
ajax_example_dynamic_sections in examples/ajax_example/ajax_example_graceful_degradation.inc
Example of a form with portions dynamically enabled or disabled, but with graceful degradation in the case of no javascript.
blog_block_configure in modules/blog/blog.module
Implements hook_block_configure().
comment_block_configure in modules/comment/comment.module
Implements hook_block_configure().
dblog_form_system_logging_settings_alter in modules/dblog/dblog.module
Implements hook_form_FORM_ID_alter().
DrupalDefaultEntityController::buildQuery in includes/entity.inc
Builds the query to load the entity.
field_ui_field_edit_form in modules/field_ui/field_ui.admin.inc
Menu callback; presents the field instance edit page.
field_ui_menu in modules/field_ui/field_ui.module
Implements hook_menu().
field_ui_table_pre_render in modules/field_ui/field_ui.admin.inc
Pre-render callback for field_ui_table elements.
form_example_states_form in examples/form_example/form_example_states.inc
This form shows off the #states system by dynamically showing parts of the form based on the state of other parts.
form_process_date in includes/form.inc
Roll out a single date element.
form_test_select in modules/simpletest/tests/form_test.module
Builds a form to test #type 'select' validation.
form_type_checkboxes_value in includes/form.inc
Helper function to determine the value for a checkboxes form element.
form_type_select_value in includes/form.inc
Helper function to determine the value for a select form element.
form_type_tableselect_value in includes/form.inc
Helper function to determine the value for a tableselect form element.
forum_admin_settings in modules/forum/forum.admin.inc
Form builder for the forum settings page.
forum_block_configure in modules/forum/forum.module
Implements hook_block_configure().
hook_block_configure in modules/block/block.api.php
Define a configuration form for a block.
hook_search_admin in modules/search/search.api.php
Add elements to the search settings form.
image_style_options in modules/image/image.module
Get an array of image styles suitable for using as select list options.
node_block_configure in modules/node/node.module
Implements hook_block_configure().
node_search_admin in modules/node/node.module
Implements hook_search_admin().
number_field_formatter_settings_form in modules/field/modules/number/number.module
Implements hook_field_formatter_settings_form().
number_field_settings_form in modules/field/modules/number/number.module
Implements hook_field_settings_form().
poll_form in modules/poll/poll.module
Implements hook_form().
queue_example_add_remove_form in examples/queue_example/queue_example.module
Provides an interface to add items to the queue, to retrieve (claim) an item from the head of the queue, and to claim and delete. Also allows the user to run cron manually, so that claimed items can be released.
search_admin_settings in modules/search/search.admin.inc
Menu callback: displays the search module settings page.
statistics_block_configure in modules/statistics/statistics.module
Implements hook_block_configure().
statistics_settings_form in modules/statistics/statistics.admin.inc
Form builder; Configure access logging.
system_cron_settings in modules/system/system.admin.inc
Form builder; Cron form.
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_site_information_settings in modules/system/system.admin.inc
Form builder; The general site information form.
update_filter_project_info in modules/update/update.compare.inc
Filter the project .info data to only save attributes we need.
update_get_update_list in includes/update.inc
Return a list of all the pending database updates.
user_block_configure in modules/user/user.module
Implements hook_block_configure().
_ajax_example_get_first_dropdown_options in examples/ajax_example/ajax_example.module
Helper function to populate the first dropdown. This would normally be pulling data from the database.
_ajax_example_get_second_dropdown_options in examples/ajax_example/ajax_example.module
Helper function to populate the second dropdown. This would normally be pulling data from the database.
_comment_per_page in modules/comment/comment.module
Return an array of "comments per page" settings from which the user can choose.

Code

includes/common.inc, line 2619

<?php
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;
}
?>