Hello,
I am currently using a text file as an array to generate table rows for each
element like so:
<?
$array1=file("file.txt");
foreach ($array1 as $line)
if (ereg("([\t])\t+([\t])\t+([\t]*)$", trim($line), $element)) {
?>
<tr>
<td><b><?php echo ($element[0]);?></td>
<td><b><?php echo ($element[1]);?></td>
<td><b><?php echo ($element[2]);?></td>
</tr>
<?php
}
?>
No problem, but for another page I would like to print certain elements of
a specific line from "file.txt" by comparing a variable to the first element
of each line.
example, if file.txt contains:
chapter1 Introduction 39pages
chapter2 The Meeting 56pages
chapter3 The End 234pages
I would like to have a script compare the called up variable "$chapter" to
each line in the file, so that if $chapter = "chapter1" , the script would
print "Introduction".
Can anyone help?
Thank you!