1, CURLOPT_URL => $url, CURLOPT_HEADER => 0 )); $result = curl_exec($curl); curl_close($curl); echo icsToJson($result); function icsToJson($icsString) { $icsEvents = explode("BEGIN:VEVENT", $icsString); $icsEvents = array_slice($icsEvents, 1); $jsonEvents = array(); foreach ($icsEvents as $event) { $startDate = ""; $endDate = ""; $summary = ""; $description = ""; $eventLines = explode("\n", $event); foreach ($eventLines as $line) { if (strpos($line, "DTSTART") !== false) { $startDate = trim(explode(":", $line)[1]); } elseif (strpos($line, "DTEND") !== false) { $endDate = trim(explode(":", $line)[1]); } elseif (strpos($line, "SUMMARY") !== false) { $summary = trim(str_replace("SUMMARY:", "", $line)); } elseif (strpos($line, "DESCRIPTION") !== false) { $description = trim(str_replace("DESCRIPTION:", "", $line)); } } if (!empty($startDate) && !empty($summary)) { $jsonEvents[] = array( "title" => $summary, "start" => date("Y-m-d H:i:s", strtotime($startDate)), "end" => date("Y-m-d H:i:s", strtotime($endDate)), "description" => $description ); } } return json_encode($jsonEvents); }