1
我有wordfilter表在MySQL中,我使用PHP從它獲取所有行並將其替換內部字符串。Wordfilter,不會取代已經過濾的內容
$string = "test string";
$result = mysqli_query($conn, "SELECT * FROM wordfilter;");
while ($row = mysqli_fetch_assoc($result))
{
$string = str_replace($row['search'], $row['replace'], $string);
}
它會像這樣:
Iteration number: (row from table) - result string
0: "tt string e"
1: ("tt", "<b>test</b>") - "<b>test</b> string e"
2: ("e", "f") - "<b>tfst</b> string f"
etc.
我希望它有這個結果"<b>test</b> string f"
(「電子」不以「f」在<b>test</b>
更換,因爲它不存在在輸入字符串中)。像這樣
謝謝你,你救了我的命。 – djmati11 2013-03-02 08:05:13