我正在分析XML链接.我现在得到了广播的标题,但我无法得到下一个广播的标题.如果有人能帮助我,我将不胜感激,
<?php
$url = 'https://hls.airy.tv/airytv/33';
$xml=simplexml_load_file("$url");
$line = 0;
$time = date( "YmdHi" );
foreach($xml->xpath('programme[@channel="33"]') as $item) {
$start = substr( (string)$item["start"], 0, -8);
$end = substr( (string)$item["stop"], 0, -8);
if ($time > $start && $time < $end) {
echo "Now : ".$item->title. "<br>";
echo "Next : ".$item->title.[$line+1];
}
$line++;
}
?>
输出
Now : Let's_Go_Thailand_Koh_Lanta;_a_place_the_discover_Ep_021
Next : Let's_Go_Thailand_Koh_Lanta;_a_place_the_discover_Ep_021Array
XML
<programme start="20220623090024 +0000" stop="20220623093300 +0000" channel="33">
<title lang="en">Let's_Go_Thailand_Koh_Lanta;_a_place_the_discover_Ep_021</title>
<sub-title lang="en">Let's_Go_Thailand_Koh_Lanta;_a_place_the_discover_Ep_021</sub-title>
<desc lang="en"/>
<date>20220623</date>
<publisher/>
<category lang="en">Featured</category>
<category lang="en">Airy TV 1</category>
</programme>
<programme start="20220623093300 +0000" stop="20220623100301 +0000" channel="33">
<title lang="en">Let's_Go_Thailand_Moment_by_Moment_Harvest_Ep_023</title>
<sub-title lang="en">Let's_Go_Thailand_Moment_by_Moment_Harvest_Ep_023</sub-title>
<desc lang="en"/>
<date>20220623</date>
<publisher/>
<category lang="en">Featured</category>
<category lang="en">Airy TV 1</category>
</programme>