【发布时间】:2015-02-10 14:04:19
【问题描述】:
<?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.";
}
?>
在这里得到很多帮助后,代码现在看起来像这样 ^ 现在我正在尝试包含下面的代码。 这样它将武器类重命名为更用户友好的名称。 我已经包含了它正在寻找的两个 .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]; }
}
【问题讨论】:
-
旁注:我无法更改它登录到 PhitLog.txt 文件的方式
-
您是否尝试过使用替换正则表达式?
-
str_replace,简单地说。 -
没有尝试过替换正则表达式不,你能告诉我怎么做吗?
标签: php arrays str-replace