Jump to content

fgetcsv


mkklepper

Recommended Posts

I have a script that writes link info to a text file, this script reads and displays the information. Everything works bit I get this error  msg [b]Notice[/b]:Undefined index: 1 in [b]c:\inetpub\wwwroot\file\path.php on line 44[/b]
[code]
$display = "file\\path.txt";

if( is_file($file($display) ) {
$fp = @fopen("$display", 'rb');
    while( $line = @fgetcsv($fp, 100, "\t") ) {
    print"<div align=\"center\"><a href=\" $line[1] \"> $line[0] </a></div>";
    }
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/24286-fgetcsv/
Share on other sites

It most likely means that one of the lines in your file does not contain the delimiter -> \t, or the end of your file contains (2) empty lines after the last line with content! fgetcsv(), only allows for a single empty line after the last line with content!


Also what is this...

[code]if( is_file($file($display) ) {[/code]

it should be...

[code]if ( is_file ( $display ) {[/code]



me!

Link to comment
https://forums.phpfreaks.com/topic/24286-fgetcsv/#findComment-110417
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.