Reputation: 23
I am reading a large CSV file through fgetcsv()
. I want to read the header of the file and the data separately. Below is my code. Any help?
$msg_row = 1;
while (($result = fgetcsv($msg_file,1000, ",")) !== false)
{
$msg_data[] = $result;
$msg_row++;
}
Upvotes: 1
Views: 82
Reputation: 224942
So call it once first?
$msg_row = 1;
$header = fgetcsv($msg_file, 1000, ",");
while (($result = fgetcsv($msg_file, 1000, ",")) !== false)
{
$msg_data[] = $result;
$msg_row++;
}
Upvotes: 4