Files
wrapartamenty.pl/wp-content/plugins/booking-manager/assets/libs/icalendar/examples/parseicalendar.php
Roman Pyrih d6241cfa7a first commit
2024-12-19 15:27:13 +01:00

39 lines
752 B
PHP

<?php
/**
* Parse iCalendar Example
*
* Enter an ics filename or URL on the command line,
* or leave blank to parse the default file.
*
*/
require_once("../zapcallib.php");
$icalfile = count($argv) > 1 ? $argv[1] : "abrahamlincoln.ics";
$icalfeed = file_get_contents($icalfile);
// create the ical object
$icalobj = new ZCiCal($icalfeed);
echo "Number of events found: " . $icalobj->countEvents() . "\n";
$ecount = 0;
// read back icalendar data that was just parsed
if(isset($icalobj->tree->child))
{
foreach($icalobj->tree->child as $node)
{
if($node->getName() == "VEVENT")
{
$ecount++;
echo "Event $ecount:\n";
foreach($node->data as $key => $value)
{
echo " $key: " . $value->getValues() . "\n";
}
}
}
}