You are here

function drupal_array_merge_deep_array in Drupal 7

Merges multiple arrays, recursively, and returns the merged array.

This function is equivalent to drupal_array_merge_deep(), except the input arrays are passed as a single array parameter rather than a variable parameter list.

The following are equivalent:

The following are also equivalent:

See also

drupal_array_merge_deep()

4 calls to drupal_array_merge_deep_array()
ajax_render in includes/ajax.inc
Renders a commands array into JSON.
drupal_array_merge_deep in includes/bootstrap.inc
Merges multiple arrays, recursively, and returns the merged array.
drupal_pre_render_scripts in includes/common.inc
The #pre_render callback for the "scripts" element.
file_ajax_upload in modules/file/file.module
Menu callback; Shared Ajax callback for file uploads and deletions.

File

includes/bootstrap.inc, line 2412
Functions that need to be loaded on every Drupal request.

Code

function drupal_array_merge_deep_array($arrays) {
  $result = array();
  foreach ($arrays as $array) {
    foreach ($array as $key => $value) {

      // Renumber integer keys as array_merge_recursive() does. Note that PHP
      // automatically converts array keys that are integer strings (e.g., '1')
      // to integers.
      if (is_integer($key)) {
        $result[] = $value;
      }
      elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) {
        $result[$key] = drupal_array_merge_deep_array(array(
          $result[$key],
          $value,
        ));
      }
      else {
        $result[$key] = $value;
      }
    }
  }
  return $result;
}