且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

跳过CSV文件的第一行

更新时间:2023-09-17 23:33:46

您可以使用 continue 跳过第一行的其余循环。

As you are keeping track of the row number anyway, you can use continue to skip the rest of the loop for the first row.

例如,将( $ num = count($ data))的开头:

if($row == 1){ $row++; continue; }

还有其他方法可以做到这一点,但只要确保当你继续, $ row 仍在递增,否则会产生无限循环!

There are other ways to do this, but just make sure that when you continue, $row is still being incremented or you'll get an infinite loop!