I have an array with the following structure
Array
(
[0] => Array
(
[area] => Area ABC
[activity] => Array
(
[0] => Activity 1
[1] => Activity 2
)
)
)
I'm trying to render this array in the following way
Area ABC
- Activity 1
- Activity 2
And am currently using the following code to achieve this
$status = 'closed';
foreach($suggestions as $suggestion)
{
if($currentarea != $suggestion['area'])
{
echo "<h3>";
echo $suggestion['area'];
echo "</h3>";
if($status == 'closed')
{
echo "<ol>";
$status = 'open';
}
}
foreach($suggestion['activity'] as $activity)
{
echo "<li>";
echo $activity;
echo "</li>";
}
if($status == 'open')
{
echo "</ol>";
$status = 'closed';
}
$currentarea = $suggestion['area'];
}
Is this the best way of doing it, or is there a better way, I will have more areas and activities, but the structure stays the same.