php - 如何使用php将ics文件导入mysql?

标签 php mysql icalendar

我想将使用 MS-outlook 发布的 ics 文件中的数据导入到 mysql 中。 如何做到这一点?

最佳答案

使用此代码。

$filename = "test.tsv";
//Read the file
$content = file_get_contents($filename);
//Split file into lines
$lines  = explode("\n", $content);

//Find columns by reading first line
$columns = explode("\t", $lines[0]);

//Construct create table
$sql_table = "CREATE TABLE IF NOT EXISTS `tsv` (\n";
//Set first column ID
$sql_table .= "  `id` int(11) NOT NULL AUTO_INCREMENT,\n";
foreach ($columns as $column) {
    //Add each column to the string as type text
    $sql_table .= "  `".addslashes($column)."` text NOT NULL,\n";
}
$sql_table .= "  PRIMARY KEY (`id`)\n) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;";

关于php - 如何使用php将ics文件导入mysql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35658274/

相关文章:

php - 我如何在 drupal 7 页面模板中创建一个 php 条件语句

php - 实时 AJAX 内容

Python MySQL 游标无法获取行

mysql - 如何通过显示最新行数据来使用组

mysql - wordpress mysql查询帖子缩略图

android - 如何将 .vcs 文件添加到 Android 日历

php - IBM (Lotus) Notes 无法识别 iCal (.ics) 文件

javascript - 使用 jquery 获取动态创建的元素的内容

php - get_categories() 只返回正在使用的类别

c# - Format string in ICS Fle(为 ICS 文件设置字体)