I am trying to create a menu calling specific array values using foreach loops with a fixed number of items (3) and each one going a tier deeper into an inner-associative array that has the information like the text to display, the background image, and the link. I have seen semi-similar questions asked around other forums but nothing that touches this particular span.
I have tried both echoing and printing the keys from the arrays but I keep getting an error that says "cannot redeclare createitem" (the function line) and that it is previously declared 8 lines later on the line with the last closing div tag. I am not really sure what is being redeclared in this case considering that is the only iteration of the function on there.
What I have tried:
$myarray = array(
<link rel="stylesheet" type="text/css" href="page.css" media="screen">
foreach ($myarray as $menuitem)
echo '<div class="backgrounddiv"><div= class="textdiv" onclick="location.href='<!--respective link for each item-->';" style="cursor: pointer;"><!--respective text for each item--></div></div>'
background-image:<!--respective image for each item-->;