You are here

function shorten_get_path_in_array in Shorten URLs 8.2

Same name and namespace in other branches
  1. 7.2 shorten.module \shorten_get_path_in_array()

Follows a path in a multidimensional array and returns a corresponding value.

Parameters

array $data: A single or multi dimensional array to extract a value from.

array $path: An single dimensional array of the nested keys to look for in $data.

Return value

The value found at the end of the path followed in the data array.

1 call to shorten_get_path_in_array()
shorten_get_value_from_json in ./shorten.module
Extracts a value from a json object given a json member name or path.

File

./shorten.module, line 422

Code

function shorten_get_path_in_array($data, $path) {
  if (isset($path[0])) {
    $element = $path[0];
    array_shift($path);
    if (isset($data[$element])) {
      $data = shorten_get_path_in_array($data[$element], $path);
    }
  }
  return $data;
}