Hi there,
I guess tia meant something like this:
This is a CSV file, having 4 columns and 3 rows.
Assuming what tia meant was that, though this time there are 4 colmns, there might be 5, 6, or 28 columns next time, and wants to have as many <td></td>'s as there are columns in the CSV file.
If that's the case, you can explode the first line into an array to get the column count (please read the comment as it may be helpful for you to understand what's going on):
It seemed that you know how to handle once you have the column number, so I'll cut it here. Hope this is what you wanted.
Good night,