I am having trouble displaying data from a PHP array. My array looks like this:
Array
(
[July] => Array
(
[0] => Array
(
[ETitle] => Launch Party
[EStart] => 2017-07-26T09:00:00
[EEnd] => 2017-04-28T17:00:00
[ELink] => http://example.dev/events/launch-party
[EStartMonth] => July
[EStartYear] => 2017
)
)
[August] => Array
(
[1] => Array
(
[ETitle] => Open Day
[EStart] => 2017-08-10T00:00:00
[EEnd] => 2017-08-11T00:00:00
[ELink] => http://example.dev/events/open-day
[EStartMonth] => August
[EStartYear] => 2017
)
[2] => Array
(
[ETitle] => Dama Google Event
[EStart] => 2017-08-20T02:00:00-07:00
[EEnd] => 2017-08-20T03:00:00-07:00
[EStartMonth] => August
[EStartYear] => 2017
[ELink] => https://www.google.com/calendar/event?eid=NjdsZW9ydmE4bWlmOHRnZ3J0dGw3MTVlamIgcnY3YTZyMTlmMjQyMHZvcmFkcWNrbW1zdG9AZw
)
)
)
What i need to display on the page a list of items grouped under headings like this, formatted with html:
<h2>July</h2>
<ul>
<li><a href="http://example.dev/events/launch-party">Launch Party</a></li>
</ul>
<h2>Augast</h2>
<ul>
<li><a href="http://example.dev/events/open-day">Open Day</a></li>
<!-- if link contains "google" string, link needs target attribute -->
<li><a target="_blank" href="https://www.google.com/calendar/event?eid=NjdsZW9ydmE4bWlmOHRnZ3J0dGw3MTVlamIgcnY3YTZyMTlmMjQyMHZvcmFkcWNrbW1zdG9AZw">Dama Google Event</a></li>
</ul>
I have tried all sorts of solutions from stack overflow but I keep ending up with invalid index warnings when I try loop through recursively. How do I solve this, and build the HTML list as described?
EDIT: updated expected result with real HTML
foreachLoop?foreachloops and recursive functions but none of them work. I am just beginning to learn PHP.