Skip to content

Instantly share code, notes, and snippets.

@jeyemwey
Created October 20, 2016 11:28
Show Gist options
  • Save jeyemwey/3240ba7a9bffe77df39fcee17b532e2a to your computer and use it in GitHub Desktop.
Save jeyemwey/3240ba7a9bffe77df39fcee17b532e2a to your computer and use it in GitHub Desktop.
<?php
$ics_file = file_get_contents("hft.ics");
#$ics_file = file_get_contents("https://www1.hft-leipzig.de/hiscal/pub/hiscalStg.php?stg=dai16");
if (!$ics_file) {
http_response_code(404);
}
$CalendarDelimiter = "BEGIN:VEVENT";
$icsArray = explode($CalendarDelimiter, $ics_file);
for ($i=1; $i < count($icsArray); $i++) {
$contains_DAI = (bool) strpos($icsArray[$i], "DAI");
$not_contain_DAI2 = (bool) !strpos($icsArray[$i], "DAI 16/2");
if($contains_DAI AND $not_contain_DAI2) { }
else {
unset($icsArray[$i]);
}
}
echo count($icsArray) . PHP_EOL;
var_dump($icsArray);
$new = implode($CalendarDelimiter, $icsArray);
#var_dump($new);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment