Jump to content

[SOLVED] foreach()


phpnewbie112

Recommended Posts

Hello, I am trying to read the lines output of a txt file using the foreach() as follow but it only returns the 1st line.

 

<?php

$handle = fopen("test1.txt", "r");
$data = fgetcsv($handle, 1000, ",");
$arr = array($data);
reset($arr);
$row = 1;

foreach ($arr as $value) {
    $num = count($data);
    $row++;
    for ($c=0; $c < $num; $c++) {
        echo $data[$c] . "<br />\n";
    }
}
fclose($handle);

?>

 

pls advice

Link to comment
https://forums.phpfreaks.com/topic/115683-solved-foreach/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.