Jump to content

[SOLVED] fopen and read file from 3rd line


mycow

Recommended Posts

Hello

I have the following code and i am trying to find a way to read the file from the 3rd line and not from the first. Is this possible?

 

$handle = fopen("file.csv", 'r');
while(($data = fgetcsv($handle, 100000, ";")) !== false)
{
list($col1, $col2, $col3, $col4) = $data;
}
fclose($handle);

 

Thank you for any help

Link to comment
Share on other sites

$handle = fopen("file.csv", 'r');
for($i=0; $i<2; $i++) $data = fgetcsv($handle, 100000, ";"); // read two rows
while(($data = fgetcsv($handle, 100000, ";")) !== false)
{
list($col1, $col2, $col3, $col4) = $data;
}
fclose($handle);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.