Advertisement
danrim

php short nav

Jun 8th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. $menuItems = [
  2.     1 => [
  3.         'label' => 'Home',
  4.         'url' => 'www.delfi.lt',
  5.     ],
  6.     2 => [
  7.         'label' => 'About',
  8.         'url' => 'www.litas.lt'
  9.     ],
  10.     3 => [
  11.         'label' => 'Contacts',
  12.         'url' => 'www.maxima.lt',
  13.     ],
  14.  
  15. ];
  16.  
  17. function createNav($item)
  18. {
  19.     $html = '';
  20.  
  21.     $html .= '<a href="' . $item['url'] . '" style="text-decoration: none; font-size:15pt; color:white;">' . $item['label'] . '</a>';
  22.  
  23.     return $html;
  24. }
  25.  
  26. function sendItems($menuItems)
  27. {
  28.     $html = '';
  29.     $html .= '<div class="nav" style="max-width: 800px; margin: auto; display: flex; justify-content: space-evenly; align-items: center; border: 2px solid yellow; background-color: orange; padding: 15px;  ">';
  30.  
  31.     foreach ($menuItems as $item) {
  32.         $html .= createNav($item);
  33.     }
  34.  
  35.     $html .= '</div>'; //end of nav wrapper
  36.     return $html;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement