Jump to content

fgetcsv and for loops


iceblox

Recommended Posts

Hi Guys,

 

Im really stuck i have been looking around and just cant seem to find the answers i need to help me with my project.

 

I want to use fgetcsv to get my csv file and i want to be able to run my scripts in segments i.e run 1000 lines then redirect the file back round carrying a start variable in the url.

 

Hope this is clear?

 

Does any one have any ideas on how i can get this to work?

 

 

This doesnt work but have this so far..

 

<?php

    $fh = fopen("contacts.csv", "r");
fgetcsv ($fh, 10000);
    for ($row = 0; $line_array = fgetcsv ($fh, 10000); ++$row)
    {

	echo "";



    }

?>

 

Thanks in advance

Link to comment
Share on other sites

Thanks for the input!

 

I gave that a try and it does sort of work however if i set counter to 500 as i want it to start there it always prints row 1 but i dont want it to start until row 500?

 

i thought id need to do something like

 

for ( $counter = 5; $counter <= 300; $counter += 10) {

 

but cannot get it to work

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.