mycal.php,PHP : Output iCalendar File as Plain Text

You need to READ or WRITE ?

for read I used in the past :

and

http://sourceforge.net/projects/phpicalendar/ --< i believe this one can also read but it is huge - you might just take a function or two from there

but - I understood by your question that you need to read - iCalender IS plain text .

You only need to open the file and plot line by line.

$data = file_get_contents("myfile.ics"); //read the file

$convert = explode("\n", $data); //create array separate by new line

for ($i=0;$i

{

echo $convert[$i].', '; //write value by index

}

?>

and then use regex or something else to give human-readeble format to the tags ..

EDIT I :

I just found a function I used before :

It uses this class : http://www.kigkonsult.se/iCalcreator/index.php

It was not written by me , but it worked for me in the past .

I do not remember the source for this function - If I will find it i will post ..

require_once 'iCalcreator/iCalcreator.class.php';

$filename = 'D:\Document\Docs\2007\05\iCal-20070508-082112.ics';

$v = new vcalendar(); // initiate new CALENDAR

$v->parse($filename);

# get first vevent

$comp = $v->getComponent("VEVENT");

#print_r($comp);

$summary_array = $comp->getProperty("summary", 1, TRUE);

echo "summary: ", $summary_array["value"], "\n";

$dtstart_array = $comp->getProperty("dtstart", 1, TRUE);

$dtstart = $dtstart_array["value"];

$startDate = "{$dtstart["year"]}-{$dtstart["month"]}-{$dtstart["day"]}";

$startTime = "{$dtstart["hour"]}:{$dtstart["min"]}:{$dtstart["sec"]}";

$dtend_array = $comp->getProperty("dtend", 1, TRUE);

$dtend = $dtend_array["value"];

$endDate = "{$dtend["year"]}-{$dtend["month"]}-{$dtend["day"]}";

$endTime = "{$dtend["hour"]}:{$dtend["min"]}:{$dtend["sec"]}";

echo "start: ", $startDate,"T",$startTime, "\n";

echo "end: ", $endDate,"T",$endTime, "\n";

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值