Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi People
The title says it all.
Undefined offset happens when my .txt or csv file has empty spaces.
Can someone look through my code and help me. I'm sure there is another way of writting the code but I'm very limited with my PHP knowledge.Code: Select all
<?php
$textfiles = "stn-numbers2.csv";
if (!($stn = fopen($textfiles,"r"))) exit ("Unable to Open $textfile");
echo "<table border="1" cellpadding="10" cellspacing="0"><tr><td>File Name</td><td>Title</td><td>Date</td><td>Modified</td></tr>\n";
while (!feof($stn)) {
$line = fgets($stn, 2048);
$out = array($line);
list($file, $title, $date, $modified) = split ('[,]', $line);
echo "<tr><td>$file</td><td><a href="http://www.artc.com.au/docs/Operations/notices/special-train-notice/stn-data/$file.pdf">$title</a></td><td>$date</td><td>$modified</td></tr>\n";
}
echo "<table>";
$stn++;
fclose ($stn);
?>Code: Select all
Notice: Undefined offset: 3 in C:\ARTC\site\elements\array.php on line 12
Notice: Undefined offset: 2 in C:\ARTC\site\elements\array.php on line 12
Notice: Undefined offset: 1 in C:\ARTC\site\elements\array.php on line 12Sample
File Name Title Date Modified
1687 Vide Vide Lidcombe-Auburn-Clyde September 7-8 3/09/2004 12:10
1687 Lidcombe-Auburn-Clyde September 7-8 3/09/2004 12:09
1303 Works Programme Operation Join Forces September 18-19 3/09/2004 12:09
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]