我想将使用MS-outlook发布的ics文件中的数据导入mysql。 怎么做?
答案 0 :(得分:0)
使用此代码。
$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 ;";