(.*?)<\/span>/s';
preg_match($titlePattern, $html, $titleMatches);
$albumTitle = $titleMatches[1];
// Check if line is already present in file
$fileContent = file_get_contents('pastreleases.html');
$lineToCheck = "" . $reformattedDate . " " . $albumTitle . "
";
if (strpos($fileContent, $lineToCheck) !== false) {
// Line is already present, display error message
echo "Error: Line already exists in the file.
";
} else {
// Line is not present, prepend to the file
$fileContentToWrite = $lineToCheck . "\n" . $fileContent;
file_put_contents('pastreleases.html', $fileContentToWrite);
}
echo "" . $reformattedDate . "";
echo " " . $albumTitle . "";
}
?>
(\d{4}-\d{2}-\d{2})/', $line, $dateMatches);
if (isset($dateMatches[1]) && strtotime($dateMatches[1]) !== false) {
$date = $dateMatches[1];
$linesWithDates[$line] = $date;
}
}
arsort($linesWithDates);
$reorderedLines = array_keys($linesWithDates);
$reorderedContent = implode("\n", $reorderedLines);
// Filter lines that do not contain "https://"
$filteredLines = array_filter($reorderedLines, function ($line) {
return strpos($line, 'https://') !== false;
});
$filteredContent = implode("\n", $filteredLines);
file_put_contents('pastreleases.html', $filteredContent);
echo "Reordering and filtering completed successfully!";
}
?>