function drupal_array_nested_key_exists

cis7 common.inc drupal_array_nested_key_exists(array $array, array $parents)
cle7 common.inc drupal_array_nested_key_exists(array $array, array $parents)
elmsmedia7 common.inc drupal_array_nested_key_exists(array $array, array $parents)
icor7 common.inc drupal_array_nested_key_exists(array $array, array $parents)
meedjum_blog7 common.inc drupal_array_nested_key_exists(array $array, array $parents)
mooc7 common.inc drupal_array_nested_key_exists(array $array, array $parents)

Determines whether a nested array contains the requested keys.

This helper function should be used when the depth of the array element to be checked may vary (that is, the number of parent keys is variable). See drupal_array_set_nested_value() for details. It is primarily used for form structures and renderable arrays.

If it is required to also get the value of the checked nested key, use drupal_array_get_nested_value() instead.

If the number of array parent keys is static, this helper function is unnecessary and the following code can be used instead:

$value_exists = isset($form['signature_settings']['signature']);
$key_exists = array_key_exists('signature', $form['signature_settings']);

Parameters

$array: The array with the value to check for.

$parents: An array of parent keys of the value, starting with the outermost key.

Return value

TRUE if all the parent keys exist, FALSE otherwise.

See also

drupal_array_get_nested_value()

2 calls to drupal_array_nested_key_exists()
drupal_validate_form in includes/form.inc
Validates user-submitted form data in the $form_state array.
_form_builder_handle_input_element in includes/form.inc
Adds the #name and #value properties of an input element before rendering.

File

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

Code

function drupal_array_nested_key_exists(array $array, array $parents) {
  // Although this function is similar to PHP's array_key_exists(), its
  // arguments should be consistent with drupal_array_get_nested_value().
  $key_exists = NULL;
  drupal_array_get_nested_value($array, $parents, $key_exists);
  return $key_exists;
}
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.