find('.card') as $card) { $item = array(); $title = $card->find('span[itemprop=text]', 0); if ($title) { $item['title'] = $title->plaintext; $pattern = '/vom ([0-9]{1,2}\\. [a-zA-ZäöüÄÖÜß]+ [0-9]{4})/'; preg_match($pattern, $item['title'], $matches); if (!empty($matches)) { $date_parts = explode(' ', $matches[1]); $date_parts[1] = $this->translateMonth($date_parts[1]); $english_date = implode(' ', $date_parts); $date = DateTime::createFromFormat('d. F Y', $english_date); if ($date !== false) { $date->setTime(0, 0); $item['timestamp'] = $date->getTimestamp(); } } } $pdf_link = $card->find('p.pdf a', 0); if ($pdf_link) { $item['uri'] = 'https://cuii.info' . $pdf_link->href; $item['uid'] = $item['uri']; $item['content'] = 'Empfehlung zum Download als PDF'; } else { $item['content'] = 'Empfehlung zum Download als PDF'; } $this->items[] = $item; } } private function translateMonth($month) { $months = array( 'Januar' => 'January', 'Februar' => 'February', 'März' => 'March', 'April' => 'April', 'Mai' => 'May', 'Juni' => 'June', 'Juli' => 'July', 'August' => 'August', 'September' => 'September', 'Oktober' => 'October', 'November' => 'November', 'Dezember' => 'December' ); return $months[$month] ?? $month; } }