Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function makeNav($pageArray){
- $output = "<ul id=\"nav\">\n";
- foreach($pageArray as $url => $label){
- $classAttribute = basename($_SERVER['PHP_SELF']) == $url ? ' class="active"' : '';
- $output .= " <li><a href=\"$url\"$classAttribute>$label</a></li>\n";
- }
- return $output . "</ul>\n";
- }
- // usage follows
- // define an array of pages and labels...
- $pages = array('index.php' => 'HOME',
- 'about.php' => 'ABOUT',
- 'projects.php' => 'PROJECTS',
- 'irrigation.php' => 'IRRIGATION',
- 'news.php' => 'NEWS',
- 'contact.php' => 'CONTACT');
- // echo the output where you need it
- echo makeNav($pages);
Add Comment
Please, Sign In to add comment