You are here

public function HMSService::array_get_nested_value in HMS Field 8

Get nested array values.

Parameters

array $array:

array $parents:

null $key_exists:

Return value

mixed

Overrides HMSServiceInterface::array_get_nested_value

File

src/HMSService.php, line 22

Class

HMSService
Provides a service to handle various hms related functionality.

Namespace

Drupal\hms_field

Code

public function array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) {
  $ref =& $array;
  foreach ($parents as $parent) {
    if (is_array($ref) && array_key_exists($parent, $ref)) {
      $ref =& $ref[$parent];
    }
    else {
      $key_exists = FALSE;
      $null = NULL;
      return $null;
    }
  }
  $key_exists = TRUE;
  return $ref;
}