function get_elem_parents($menu, $find, $parents = array()) { for ($i = 0, $n = count($menu); $i < $n; $i++) { $elem = $menu[$i]; if ($elem["href"] == $find) { return $parents; } if (isset($elem["menu"])) { if (find_elem_in_menu($elem["menu"], $find)) { $parents[] = array("title" => $elem["title"], "href" => $elem["href"]); return get_elem_parents($elem["menu"], $find, $parents); } } } return $parents; }
<ol class="breadcrumb"> <li><a href="/"><?php echo translateMe("Главная"); ?> </a></li> <?php global $uri; $breadcrumb_menu = get_elem_parents($config["menu"]["main"], $uri); for ($i = 0, $n = count($breadcrumb_menu); $i < $n; $i++) { echo "<li><a href='" . $breadcrumb_menu[$i]["href"] . "'>" . translateMe($breadcrumb_menu[$i]["title"]) . "</a></li>"; } ?> <li class="active"><?php content("name"); ?> </li> </ol>