<?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.";
}
?>
&#13;
在这里得到很多帮助后,代码现在看起来像这样^ 现在我想尝试包含下面的代码。 这样它就会将武器类重命名为更友好的用户名。 我已经包含了它寻找的两个.php文件,但我不确定我放置它的位置,如果它会像它一样运行,我怀疑。
可以有人
if ($line_type == 'kill') {
include("killfeed_weapon_classnames.php");
include("killfeed_weapon_cleannames.php");
$swap_key = array_search($line_varlist['weapon'], $wcn);
if($swap_key != false) { $line_varlist['weapon'] = $wn[$swap_key]; }
}
&#13;
答案 0 :(得分:0)
在所有preg匹配之前和$ contents使用之后:
$contents = str_replace("(Arma-AH.net)", "(DayZNorway.com)", $contents);
编辑忘了括号和下一个问题。我不打算给你下一部分,但请看下面的例子并按照这一点来帮助你实现你想要的下一个问题。
$myArray = array("firstName" =>"sam", "secondName" => "billy", "thirdName" => "sally");
$nameKey = array_search("billy", $myArray);
echo $nameKey;
if($nameKey){
$myArray[$nameKey] = "Tom";
}
print_r($myArray);
答案 1 :(得分:0)
<?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.";
}
?>
这就是我最终做的事情,现在它几乎不漂亮,但它确实有效。 现在我需要将结果按降序显示。
有人可以帮助我吗?