Source Code for /public/03-lists-and-loops/navigation-menu-2.php

<?php
/**
 * This example uses the Daily Life Sepia Icons by Asam Munir.
 * Were this a real site, you'd want to credit Asam in the text
 * of the page somewhere, not just in a comment!
 *
 * https://www.svgrepo.com/collection/daily-life-sepia-icons/
 */

 // Set up an array of links - each link is itself an array with
// a title, icon, and href:
$links = [
  [
    'title' => 'Home', 'icon' => 'home.svg',
    'href'  => '/'
  ],
  [
    'title' => 'Blog', 'icon' => 'megaphone.svg',
    'href'  => '/blog'
  ],
  [
    'title' => 'My Itch.io games', 'icon' => 'controller.svg',
    'href'  => 'https://dan-q.itch.io/'
  ],
  [
    'title' => 'Ideas bin', 'icon' => 'light-bulb.svg',
    'href'  => '/ideas'
  ],
  [
    'title' => 'Code snippets', 'icon' => 'code.svg',
    'href'  => '/my-code-snippets'
  ],
  [
    'title' => "Awards I've won!", 'icon' => 'award.svg',
    'href'  => '/awards.html'
  ],
];

// If it's NOT Monday, add a link to the Not-Monday page:
if( date('w') !== '1' ) {
  $links[] = [
    'title' => 'The Special Page!', 'icon' => 'star.svg',
    'href'  => '/closed-on-mondays.php', 'class' => 'secret'
  ];
}
?>

<nav>
  <ul>
    <?php foreach( $links as $link ) { ?>
      <li class="<?php echo $link['class']; ?>">
        <a href="<?php echo $link['href']; ?>">
          <img
            src="/img/icons/<?php echo $link['icon']; ?>"
            alt="">
          <?php echo $link['title']; ?>
        </a>
      </li>
    <?php } ?>
  </ul>
</nav>