1
我遇到問題時,某些單詞全部大寫,而其他單詞不全。即使他們是大寫的,我也需要找到單詞或短語。我需要根據數據庫在文本中搜索單詞或短語
這裏是我的代碼:
$a = "I have a FREE offer of leads for you and you need to CLICK HERE right now before this FREE opportunity passes you by. You can make money right away. visit our website right now and don't pass on this!";
$result = mysqli_query($res, "SELECT sword FROM words");
$myrow = mysqli_fetch_array($result);
while ($myrow = mysqli_fetch_array($result)){
$sword = strtolower($myrow['sword']);
if (preg_match("/$sword/", $a)) {
echo "Found $myrow[sword]!<br /><br />";
}
}
我在一個數據庫中的單詞和短語的列表。它找到機會,賺錢,領導。但它不會找到免費優惠,免費的機會,點擊這裏即使我有免費優惠,免費的機會,點擊這裏數據庫全部小寫。
我該怎麼做才能確保它能夠找到這些短語和單詞,而不管它們是全部大寫,是大寫還是全小寫?