Forum Moderators: coopster
$file = "c:test.csv";
//put file into an array
$data= file($file) or die("could not read!");
for ($i = 0; $i < count($data); $i++)
{
echo("$data[$i] <BR>\n");
}
//print file contents
echo "all done.";
?>
thank you for all the help :)
foreach ($array_of_file as $row) {
list ($var1, $var2, $var3, ..., $var21) = each ($row);
}
<?php
$row = 1;
$handle = fopen("test.csv", "r");
while ($data = fgetcsv($handle, 1000, ",")) {
$num = count($data);
echo "<p> $num fields in line $row: <br />\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
?>