1 token.inc token_flatten_tree($tree)

Flatten a token tree.

Parameters

array $tree: An array of tokens as returned by token_build_tree().

Return value

array: The array of tokens as flat array.

File

core/includes/token.inc, line 578
Backdrop placeholder/token replacement system.

Code

function token_flatten_tree($tree) {
  $result = array();
  foreach ($tree as $token => $token_info) {
    $result[$token] = $token_info;
    if (isset($token_info['children']) && is_array($token_info['children'])) {
      $result += token_flatten_tree($token_info['children']);
      unset($result[$token]['children']);
    }
  }
  return $result;
}