我有一个像这样的csv文件:
"Name","surname","note"
"Jhon","Jhon","fdskngkfngkfnkglnlksanjlbgsjangkjlvnkajsdf"
"Jhon2","Jhon2","fdssfsfsfkngkfngkfnkglnlksanjlbgsjangkjlvnkajsdf"
"Jhon3","Jhon3","fdssfsfsfkngkfngkfnk
glnlksanjlbgsjangkjlvnkajsdf"
"Jhon4","Jhon4","fdssfsfsf
kngkfngkfnkglnlks
anjlbgsjangkjlvnkajsdf"
我需要加入返回的行,因为我需要在mySQL中添加这个文件。
我使用此代码
$csv_file = "output.csv";
$csvfile = fopen($csv_file, 'r');
$theData = fgets($csvfile);
$i = 0;
while (!feof($csvfile))
{
$csv_data[] = fgets($csvfile, 1024);
$csv_array = explode('","', $csv_data[$i]);
$insert_csv = array();
$insert_csv['Gestore'] = ltrim($csv_array[0], '"');
echo $insert_csv['Gestore'] . "</br>";
$query = "INSERT INTO prova(Gestore) VALUES('".$insert_csv['Gestore']."')";
$n=mysql_query($query, $connect );
$i++;
}
它有效,但我需要解决先例问题......
答案 0 :(得分:0)