On 2016-06-08 7:12 AM, Gus wrote:
> Yes that worked! Thank you...
> However, having some difficulty as I am trying to convert to a
> 2-dimentional json by pulling 'summary' and 'dtstamp' only
>
> ~~~
> $source = file_get_contents('http://hostname/theicalfee.ics'
> <http://hostname/theicalfee.ics'>);
> $vobj = VObject\Reader::read($source);
> $json = json_encode($vobj);
> $contdecode = json_decode($json);
>
> $item=array();
> foreach ( $contdecode['vevent'] as $value ) {
> $result['Date'] = date("l - M jS",strtotime($value['dtstart'])) ;
> $result['Schedule'] = $value['summary'];
> array_push($item,$result);
> }
>
> echo json_encode($item,JSON_PRETTY_PRINT);
Turning it into json and back doesn't make a lot of sense. The whole
point of vobject is that it helps you read iCalendar. Plus, you're
making a lot of assumptions about how the json structure actually looks
like. You should consider taking a look at the actual output of your
original json_encode.
Regardless, you don't need these two lines:
> $json = json_encode($vobj);
> $contdecode = json_decode($json);
Just work with $vobj directly. There's a whole bunch of documentation on
the site:
http://sabre.io/vobject/icalendar/
Evert
--
You received this message because you are subscribed to the Google Groups
"SabreDAV Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sabredav-discuss/5eb4b65c-221f-4b63-b966-b0946b1bad95%40evertpot.com.
For more options, visit https://groups.google.com/d/optout.