Hi everyone -
Newbie to PHP.
I'm parsing an ASCII file from my FTP site with PHP and it's working just fine. I want to know if I can get help on scripting to sort the file by current date and limiting the record return. There are over 50 records and I would like to display 8-10 at a time sorted by date and display ONLY the current date.
Any help would be most appreciated.
Here's the sample CSV .txt:
sampleASCII.TXT
AWE,290,COM,,ABQ,12-07-2007 05:16:00,12-07-2007 05:16:00,,LAS,12-07-2007 06:32:00,12-07-2007 06:32:00,,S,01:16
FFT,4835,COM,,DEN,12-07-2007 05:07:00,12-07-2007 05:07:00,,ABQ,12-07-2007 06:07:00,12-07-2007 06:07:00,,S,01:00
Sample PHP code:
<?php
// open XML tags
echo "<?xml version='1.0'?>";
echo "<flightdata>";
// set file to read
$filename = "sampleASCII.txt";
// open file
$fh = fopen ($filename, "r") or die("Could not open file");
// read file
while (!feof($fh))
{
// create XML structure
echo "<schedule>";
$fields = fgetcsv($fh, 1000);
?>
<br />
<table width="1200" border="0" cellpadding="2" cellspacing="1" bordercolor="#666666">
<tr>
<td width="43" bgcolor="#FFFFFF">
<?php echo "<airline>" . $fields[0] . "</airline> "; ?>
<?php echo "<id>" . $fields[1] . "</id> "; ?>
<?php echo "<depart>" . $fields[4] . "</depart> "; ?>
<?php echo "<time>" . $fields[6] . "</time>"; ?>
</tr>
</table>
<?php echo "</flightdata>";
}
// close file
fclose ($fh);
echo "</schedule>";
?>