Hello,
I am a bit new to php and trying to wrap my mind around fgetcsv. I want to read my csv file and output the different fields into different html files. (Basically so I can format each row in a certain way in a different file per each row of data).
What I believe I need to do is somehow use fopen in a loop. I also believe I need to somehow isolate each record of data in the different rows of the array. Then, I believe I could place each record in the row into my fwrite statement (also within the loop) and output the file in a type of template.
I understand that the code:
$handle = fopen("file.txt", "r");
while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
$all_data[] = $data;
$plot1 = $data[1];
$plot2 = $data[3];
echo $plot1 . "<br />\n";
}
will output a particular column of data - the problem is it outputs the entire column - and I am trying to figure out how I could pick out each particular row/column piece of data as I loop through - sort of like coordinates. Then I would perhaps assign those "coordinates" to a variable and hopefully be able to use fopen, open or create a new file, within the loop and actually write a bunch of html files - 1 per row - by placing these seperate coordinates, or records, in what I end up placing in the variable for fwrite.
How would I go about isolating each row/column record in my csv file so I can use it. Also, how then maybe would a simple example of using these isolated parts in the while loop? Would I need embedded for loops or foreach loops perhaps?
Thanks very much in advance!
zm