function get_ul($array, $title, $child = FALSE) { $str = ''; $c = 1; $str .= $child == FALSE ? '<ul id="nav2" >' : '<ul>'; $str .= '<li><a data-scroll-nav="' . $c++ . '">Rates</a></li><li><a data-scroll-nav="' . $c++ . '">Wheather</a></li>'; if (count($array)) { foreach ($array as $item) { $str .= '<li ' . $item['id'] . '">'; if ($title == "") { $str .= '<a data-scroll-nav="' . $c++ . '">'; } else { $str .= '<a href="' . site_url($item['title']) . '" >'; } $str .= str_replace("_", ' ', $item['title']); $str .= '</a>'; // Do we have any children? if (isset($item['children']) && count($item['children'])) { $str .= get_ul($item['children'], $title, TRUE); } $str .= '</li>' . PHP_EOL; } } $str .= '</ul> ' . PHP_EOL; return $str; }
function get_ul($array, $child = FALSE) { $str = ''; if (count($array)) { $str .= $child == FALSE ? '<ul id="nav2" >' : '<ul>'; foreach ($array as $item) { $str .= '<li ' . $item['id'] . '"><a href="' . site_url($item['title']) . '" >'; $str .= '<div>'; $str .= str_replace("_", ' ', $item['title']); $str .= '</div> </a> '; // Do we have any children? if (isset($item['children']) && count($item['children'])) { $str .= get_ul($item['children'], TRUE); } $str .= '</li>' . PHP_EOL; } $str .= '</ul> ' . PHP_EOL; } return $str; }