如何使用fgetcsv()重置文件指针?
我有下面的循环,嵌套在另一个while循环中。然而,它从断点开始读取CSV,而不是在第一次运行后从开始读取CSV。
while($line2 = fgetcsv($fp2, $length2, $fildDelineate2)) {
if($line[0] == $line2[0]) {
$desc = addslashes(strip_tags($line2[6]));
$import2 = "insert into $table2 values('$id','1',\"$line[1]\",'$desc','','0')";
mysql_query($import2) or die('import2 '.mysql_error());
$count++;
break;
}
}发布于 2012-02-28 22:10:45
您可以使用rewind()或fseek()来完成此操作:
rewind($fp2);
// ...is the same as:
fseek($fp2, 0);发布于 2012-02-28 22:09:03
rewind()
发布于 2012-02-28 22:14:44
继续是最好的解决方案...尝尝这个
continue 2 ;https://stackoverflow.com/questions/9483398
复制相似问题