# booking-manager/2.1.7/assets/libs/icalendar/examples/parseicalendar.php

Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar, version 2.1.7. 39 lines.

- Page: https://pluginprobe.com/plugins/booking-manager/2.1.7/code/assets/libs/icalendar/examples/parseicalendar.php
- Raw: https://pluginprobe.com/plugins/booking-manager/2.1.7/raw/assets/libs/icalendar/examples/parseicalendar.php
- Modified: 2022-08-04T08:46:10+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/booking-manager/2.1.7/code/assets/libs/icalendar/examples/parseicalendar.php#L10-L20`.

```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";
			}
		}
	}
}

```
