Теперь у меня работает следующее решение. Если у вас есть предложения по более чистому способу, не стесняйтесь комментировать;)
<?php
//Feed URLs
$feeds = array(
"https://www.abda.de/?type=1102",
"https://www.abda.de/?type=1100",
);
//Read each feed's items
$entries = array();
foreach($feeds as $feed) {
$xml = simplexml_load_file($feed);
$entries = array_merge($entries, ($xml->xpath("//item")));
}
//Sort feed entries by pubDate
usort($entries, function ($feed1, $feed2) {
return strtotime($feed2->pubDate) - strtotime($feed1->pubDate);
});
//Find latest date in array $max = max(array_map('strtotime', $arr));
$highestdate_entries = date('d-m-Y', max(array_map('strtotime', $entries))); /* returns format 02-06-2020 */
$entries_filtered = array_filter($entries, function ($var) use ($highestdate_entries) {
return date('d-m-Y',(strtotime($var->pubDate))) === $highestdate_entries; /* -> returns 1 */
});
//Reset the array so eg. id 10 moves to id 0
$entries_filtered = array_values($entries_filtered);
//Count the amount of items, so the for loop can be adjusted to that
$numberofitems_entries = count($entries);
$numberofitems_entries_filtered = count($entries_filtered);
//echo "Items in entries : " . $numberofitems_entries . "<br>";
//echo "Items in entries_filtered : " . $numberofitems_entries_filtered . "<br>" ;
//echo "Latest date in entries : " . $highestdate_entries . "<br>" ;
//echo strtotime($entries_filtered[0]->pubDate) . " === " . strtotime($dateoftoday);
// XML feed provides 50 items per feed. Total is 100 items.
// $dateoffeed=strftime("%d-%m-%y",strtotime($entries[0]->pubDate));
// echo $dateoftoday;
// Date format in xml feed: Thu, 28 May 2020 12:17:38 +0200
// Date format from date: Mon, 01 Jun 2020 10:13:48 +0200
// $dateoftoday=date(DATE_RFC2822);
function showrssitem($i) {
global $entries_filtered;
$backgroundbutton = 'd3d3d3';
switch ($entries_filtered[$i]->category) {
case "Chargenrückrufe" :
$backgroundbutton = 'ff9933'; /* orange */
break;
case "Rückrufe" :
$backgroundbutton = 'ff9933'; /* orange */
break;
case "Informationen der Institutionen und Behörden" :
$backgroundbutton = 'ff3300'; /* red */
break;
case "Informationen der Hersteller" :
$backgroundbutton = 'ff5500'; /* red 2 */
break;
case "AMK-PhaGro-Schnellinformationen" :
$backgroundbutton = 'ff7700'; /* red3 */
break;
}
$strippedentry1 = str_replace ("Online-Nachricht: ","", $entries_filtered[$i]->title);
$strippedentry2 = str_replace ("Informationen der Institutionen und Behörden: ","", $strippedentry1);
$strippedentry3 = str_replace ("Informationen der Hersteller: ","", $strippedentry2);
echo '<td style = "border=0px !important; width:20%"><a style="text-decoration: none;" target="_blank" href="' . $entries_filtered[$i]->link . '"><button style="background-color: #' . $backgroundbutton . '; margin-bottom: 0px; width: 100%; height:50px; display: block; border-radius: 10px;">' . $entries_filtered[$i]->category . '</button></a></td>';
echo "<td><i>" . strftime('%d/%m/%Y', strtotime($entries_filtered[$i]->pubDate)) . ":</i> ";
echo mb_strimwidth($strippedentry3,0,200,"...") . '</td>';
}
?>