Good morning. I have a tab delimited .txt file that I am trying to read. I currently have the complete file displaying, but I want the last few lines to display only. Any help would be appreciated. Here is the code I have so far.
<?php // find the most current file in the $dir directory $dir = "file/path"; $dh = opendir($dir); $last = 0; $name = " "; while (($file = readdir($dh)) !== false){ if(is_file($dir.$file)){ $mt = filemtime($dir.$file); if($mt > $last){ $last = $mt; $name = $file; } } } closedir($dh); //displays most current file echo "$name " . date ("F d Y H:i:s.", filemtime($dir.$name)); $theFile=fopen($dir.$name,"r"); //run an error check on the variable to make sure we received a data stream if(!$theFile){ print "Couldn't open the data file. Try again later.
"; } else{ while(!feof($theFile)){ $data=explode("\t", fgets($theFile)); if(sizeof($data)==5){ print "