Guest User

Untitled

a guest
Jul 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2. function makeNav($pageArray){
  3. $output = "<ul id=\"nav\">\n";
  4. foreach($pageArray as $url => $label){
  5. $classAttribute = basename($_SERVER['PHP_SELF']) == $url ? ' class="active"' : '';
  6. $output .= " <li><a href=\"$url\"$classAttribute>$label</a></li>\n";
  7. }
  8. return $output . "</ul>\n";
  9. }
  10.  
  11. // usage follows
  12. // define an array of pages and labels...
  13. $pages = array('index.php' => 'HOME',
  14. 'about.php' => 'ABOUT',
  15. 'projects.php' => 'PROJECTS',
  16. 'irrigation.php' => 'IRRIGATION',
  17. 'news.php' => 'NEWS',
  18. 'contact.php' => 'CONTACT');
  19.  
  20. // echo the output where you need it
  21. echo makeNav($pages);
Add Comment
Please, Sign In to add comment