Hello everybody.
I have been handed a rather tricky, if not impossible, task.
I need to run a script that will open a tab delimited txt file, and that find a specific information on it.
Eg. let say the file look like this
aa ab ac ad
ba bb bc bd
ca cb cc cd
da db dc dd
using the below script I can nicely "slice" the file into rows an columns and display a table view:
<?php
$filename = "temp/PriceChg.TXT";
$fd = fopen ($filename, "r");
$contents = fread ($fd,filesize ($filename));
fclose ($fd);
$endofline = "\n";
$delimiter = "\t";
$line = explode($endofline, $contents);
$lncounter = 0;
?>
<br><br>
<font color="blue" face="arial" size="4">Split File Contents</font>
<hr>
<table border="1">
<?
foreach ( $line as $newline )
{
$counter = $lncounter++;
echo "<tr>";
$cell = explode($delimiter, $newline);
foreach ( $cell as $newcell){
echo "<td>".$newcell."</td>";
}
echo "</tr>";
}
?>
</table>
but, what I will need to do is to find value of specific "cell" from that list.
something like this:
display value of cell aa if value of cell ad is equal to someValue
if I could operate on database that would be a piece of cake, but I'm limited to files.
Any ideas how to do it?
Thanks