This is my first time here.
I have a problem with my foreach loop, it only outputs the “Contact Us” link and none of the others.
I can’t see a problem with my syntax:
<?php
echo '<nav id="main_nav">';
$links = array(
'#' => 'Home',
'#' => 'About Us',
'#' => 'Our Services',
'#' => 'Portfolio',
'#' => 'Testimonials',
'#' => 'Gallery',
'#' => 'Contact Us'
);
foreach($links as $href => $label){
echo '<a href="',$href,'">',$label,'</a>';
}
echo '</nav>';
?>
That is becuase of same index elements in your array……..
?>
and the answer is
<nav id="main_nav"><a href="0">Home</a><a href="1">About Us</a><a href="2">Our Services</a><a href="3">Portfolio</a><a href="4">Testimonials</a><a href="5">Gallery</a><a href="6">Contact Us</a></nav>