0
votes

I have a small doubt regarding the offsets. Suppose I have a csv file like this:

1
8 9 10 11 12 13 14 15 16 17 18 19 20

I am simply using fgetcsv function to retrieve data from csv to my php page. Here's the code: $fp = FOPEN ("so-csv.csv","r"); $data = FGETCSV ($fp, 1000, ",") symbol date . . .

data[0] shows "1" but data[1] is undefined offset. var_dump($data[1]) displays NULL. I believe I am accessing row-1 col-B of csv through data[1] which is null. How do I access next row (element 8)? Thnx

2

2 Answers

1
votes
while($data = fgetcsv($fp,1000, ",")) {
    // your processing code here
}

that's all you should need

0
votes

The fgetcsv function only reads in one line at a time. To get the second line of the file, you simply need to call the function a second time.