I am trying to read an excel file that has been saved as a Comma Separated Values file.
When I open the file with a text editor each line consists of that which was on the respective row in the original Excel file. However, when I read the file using PHP each “line” has far more values than was in each row; PLUS I have no idea what PHP is using to decide where these lines start and end! This is probably causing some of my document to be cut out as well.
I am lost please help, perhaps I don’t understand what PHP means by a “line.” My code is below. I am starting at 10 so that the first row will be skipped, as there are 10 columns in the document.
<html>
<title>File Reader</title>
<body>
<?php
$cell = 10;
if (($handle = fopen("file.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
while ($cell < $num) {
for ($row=0; $row < 10; $row++) {
echo $data[$cell]." ";
$cell++;
}
echo "<br />";
}
}
fclose($handle);
}
?>
</body>
</html>