I have CSV file with 1000s of rows and two columns.
I have a script that echos one row at a time (both columns) using this code:
[php]if( ($handle = fopen($filename, “r”)) !== FALSE )
{
$columns = fgetcsv($handle, 4096,",", ‘"’ );
if (!$columns) {
$error['message'] = 'Empty';
return ($error);
}
while( ($row = fgetcsv($handle, 4096,",", ‘"’ )) !== FALSE )
{
echo $row[0];
echo $row[1];
}
}[/php]
$row[0]; gives me row 1, column 1
$row[1]; gives me row 1, column 2
It works really nicely. However, I can’t seem to figure out how to obtain two rows at a time and separate them using a dash -----.
For example,
when I echo $row[0], I want it to contain:
Content of ROW 1, COLUMN 1
---- <-- with these dashes
content of ROW 2, COLUMN 1
AND when I echo $row[1], I want it to contain:
Content of ROW 1, COLUMN 2
---- <-- with these dashes
content of ROW 2, COLUMN 2
Any thoughts?