$item) { $index[$item['link']['mlid']] = array( 'key' => $key, 'parents' => $ancestors, ); if (!empty($item['below'])) { $index += _dhtml_menu_index($item['below'], $ancestors, $item['link']['mlid']); } } return $index; } /** * Keeps track of ID attributes and adds a suffix to make it unique-when necessary. */ function _dhtml_menu_unique_id($id) { static $ids = array(); if (!isset($ids[$id])) { $ids[$id] = 1; return $id; } else { return $id . '-' . $ids[$id]++; } }