Kimzer Posted February 23, 2015 Share Posted February 23, 2015 <?php$file = "C:\folder\log.txt";// file() (PHP 3, PHP 4, PHP 5)// read the file into array$ar_log = file($file);// flip the array$ar_log = array_reverse($ar_log);// convert array to string$log = implode('',$ar_log);// print resultecho '<pre>'.$log.'</pre>'; ?> I have this bit of code that outputs some logs from a txt file in descending order for me. This works absolutely awesome and does the trick. However, i am trying to replace some text wich is in that .txt so that it changes on the output of the website. The text i am trying to replace is Arma-AH.net to DayZNorway.com Now i have fiddled around with str_replace but i simply cannot get it to work. I am not good at this so i desperately need some assistance. I also would have loved to be able to filter out quotation marks and place it all in tables with text explaining what each table includes. Such as Playername, Killed, weapon, and so on.. You get the jist. Preferrably on a black background with a colored text if doable.. Then i have this second script. <?php$file = 'C:\wamp\www\Killboard\EPChernarus1\PhitLog.txt';$searchfor = 'Chernarus';header('Content-Type: text/html');$contents = file_get_contents($file);$contents = str_replace("(ArmA-AH.net)", "(DayZNorway.com)", $contents);$pattern = preg_quote($searchfor, '/');$contents = str_replace("DayZ Instance: 11", " Map: Chernarus ", $contents);$pattern = "/^.*$pattern.*$/m";$contents = str_replace("PKILL", "Player Killed", $contents);$contents = str_replace("CLOG", "Combat Logged", $contents);if(preg_match_all($pattern, $contents, $matches)){echo "<strong>";echo "<div style ='font:11px/21px Arial,tahoma,sans-serif;color:#2983CB'>Killboard Epoch Chernarus: <br>";echo '', implode(" <br>", $matches[0]);echo "</strong>";}else {echo "No kills yet. Looks like everyone is playing nice.";}?> Wich does some of the same, atleast for the replacing. But here i just want it to display in descending order instead. Its far from pretty, i know, so if someone wants to clean it up aswell. That would be much appreciated too. Hope someone can help out a php noobie here Quote Link to comment Share on other sites More sharing options...
requinix Posted February 23, 2015 Share Posted February 23, 2015 Can you post a sample from the file? Quote Link to comment Share on other sites More sharing options...
Kimzer Posted February 24, 2015 Author Share Posted February 24, 2015 [2015-01-27 16:24:07] (ArmA-AH.net) : Misc Log: SpK.Silvia (76561197999559055) REASON: Side Chat LOG: (3/3 chances used) - |DayZ Instance: 7| ^ Random log output =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.