Parse txt file displayed into tables in php/html

alastairburiss

New Member
I've just created a script to grab the ip, hostname, and date and put into a text file. I wanted to create another script to display this information into a .php with some tables to make it easy to read.This is the code I'm using to write to the file it works perfect. I just don't know how to parse it to do what I want it to do.\[code\]$logFile = 'IPLog.txt';$fh = fopen($logFile,'a') or die("can't open file");$ip = $_SERVER['REMOTE_ADDR'];$fullhost = gethostbyaddr($ip);$stringData = http://stackoverflow.com/questions/15855511/date('m/d/y | h:ia') . " - " . $ip . ":" . $fullhost . "\n";fwrite($fh, $stringData);fclose($fh);\[/code\]The output looks like this..04/06/13 | 02:53pm - xxx.xxx.xxx.xxx:xxx.comcast.netI'm waiting the script to read the file and display it in tables such as.\[code\]IP Address | Hostname | Date | Time----------------|-------------------|-------------|-----------------------------xxx.xxx.xxx.xx | xxx.comcast.net | 04/06/13 | 02:53pm--------------------------------------------------------------------------------xxx.xxx.xxx.xx | xxx.comcast.net | 04/06/13 | 02:53pm--------------------------------------------------------------------------------xxx.xxx.xxx.xx | xxx.comcast.net | 04/06/13 | 02:53pm--------------------------------------------------------------------------------xxx.xxx.xxx.xx | xxx.comcast.net | 04/06/13 | 02:53pm--------------------------------------------------------------------------------\[/code\]So I want it to just make a nice little table to display the information so I can just check it real fast and it looks nice.There isn't any particular reason why I want this. I am only using this for an example of how to parse a text file. I have never been good at it and really want to learn how it's done. So I could use this for other things if I wanted too.
 
Back
Top