- time: documentation ( source)
- simplexml_load_file: documentation ( source)
<?php
$url = 'http://tvprofil.net/xmltv/data/cnn.info/weekly_cnn.info_tvprofil.net.xml';
$xml = simplexml_load_file($url);
$startTimeUnix = time() - 7200;
$i = 0;
foreach($xml->programme as $programm)
{
$start = DateTime::createFromFormat('YmdHis', $programm->attributes()->start)->getTimestamp();
if ($start > $startTimeUnix)
break;
$i++;
}
echo '<b>Now:</b> ' , $xml->programme[$i]->title , '<br/>';
echo '<b>Next:</b> ', $xml->programme[++$i]->title;