I have a simple XML list with dates inside (chronological order). I have found a way loop the list 7 times (1 week).
<?php
$xmldata=simplexml_load_file("dates.xml");
$i = 0;
foreach($xmldata->day as $day) {
if($i==7) break;
$i++;
echo "<p>Date: " . $day->date . "</p>";
echo "<p>Dayname: " . $day->content . "</p>";
}
?>
Now I have the problem, that the loop always starts at the first line of the XML file and ends after 7 times. But I want to start the loop, when
$xmldata->day->date = $currentday;
$currentday = date('d.m.y');
and continue with the next 7 items (days) in the list.
The XML (dates.xml) looks like this:
<schedule>
<day>
<date>01.03.17</date>
<information>Lorem ipsum</information>
</day>
<day>
<date>02.03.17</date>
<information>Lorem ipsum</information>
</day>
<day>
<date>03.03.17</date>
<information>Lorem ipsum</information>
</day>
...
</schedule>
Thank you!