简体   繁体   English

PHP-从文件底部显示输出

[英]PHP - Display output from bottom of file

<?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.";
}

?>

How can I get this to display the lines from bottom of file first? 我怎样才能首先显示文件底部的行? I'm guessing some sort of array reverse but I couldnt make that work. 我猜想某种数组反向,但我不能使它工作。

Can someone show me please? 有人可以告诉我吗?

Change 更改

echo '', implode(" <br>", $matches[0]);

to

echo '', implode(" <br>", array_reverse($matches[0]));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM