Re: Reading from various .txt files in directory
| From: | Justin French | Date: | Tue, 27 May 2003 11:24:32 +0000 |
| Subject: | Re: Reading from various .txt files in directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-149096@lists.php.net to get a copy of this message | ||
1. read the filenames of the directory into an array
see http://www.weberdev.com/get_example.php3?count=3636
for an example
2. loop through the array, opening each and getting the contents of each
file.
see http://au.php.net/file-get-contents or
see http://www.weberdev.com/get_example.php3?count=3635
3. with each file's contents, do this:
<?
$dataItems = explode('%',$fileContents);
echo "<tr>";
echo "<td>$dataItems[1]</td>";
echo "<td>$dataItems[2]</td>";
echo "<td>$dataItems[3]</td>";
echo "<td>$dataItems[6]</td>";
echo "</tr>";
?>
Hope that helps
Justin
on 27/05/03 7:08 PM, TWSC HQ (admin@twsc.co.za) wrote:
> Hi guys,
>
> Is the following possible and how do you do it?
>
> I have various .txt files in a single directory - all in the same format:
>
> Content of abc.txt file:
>
> 1%23%5%2003%0.00%0.00%7.78
>
> Content of def.txt file:
>
> 9%20%5%2003%0.00%0.00%100.00
>
> Data is seperated by a % sign -
> Now, how do I display the 2nd, 3rd, 4th and last entry (for each file in the
> directory) in table format in a browser?
>
> In other words I need the output to be in browser :
>
> 23 5 2003 7.78
> 20 5 2003 100.00
>
> Trick is that the .txt file names are randomly generated - they can be
> abc.txt, gyu.txt, iyu.txt etc.
>
> Any help or ideas would be appreciated!
>
> thanx!
>
> August
>
>
>
>
>
>