> The for loop iterates through each field of each line, the while loop
> iterates through each line. Move the <br /> out of the for loop, right
> before the end of the while loop as follows:
> <?php
> $row = 1;
> $handle = fopen("try3.csv", "r");
> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
> $num = count($data);
> echo "<p> $num fields in line $row: <br /></p>\n";
> $row++;
> for ($c=0; $c < $num; $c++) {
> echo $data[$c] . " "; // This will separate each field with a space.
> }
> echo "<br />\n";
> }
> fclose($handle);
> ?>
>
hi guys,
here is a shortcut to displaying a line of csv.
instead of using for loop, use implode like this.
echo implode(' ', $data) . "<br />\n";
that would display the fields separated by spaces.
Virgil
http://www.jampmark.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php