I have a multidimensional array which I want to display in a foreach loop. I've been looking at lots of tutorials but I haven't been able to make it work yet.
This is my array and foreach loop:
$events = array(
array( Name => "First Event",
Date => "12/13/14",
Time => "12:13"
Description => "event description"
),
array( Name => "Second Event",
Date => "12/13/14",
Time => "12:13",
Description => "event description"
),
array( Name => "Third Event",
Date => "12/13/14",
Time => "12:13"
Description => "event description"
)
);
foreach($events as $event) {
echo "<div class=\"event\"><strong>";
echo $event[Name];
echo "</strong><em>";
echo $event[Date] . " at " . $event[Time];
echo "</em><div>";
echo $event[Description];
echo "</div></div>";
}
and here is how I want it to display:
<div class="event">
<strong>Event Name</strong><em>Date at Time</em>
<div>
Description
</div>
</div>
I would appreciate any help you could give. Thanks!
foreach
? We are happy to help you debug your code, but we aren't going to write it for you. – adear11 Jan 1 at 18:46