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
https://forums.phpfreaks.com/topic/168987-fgetcsv-and-for-loops/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.