我在使用 str_ireplace 和从数据库表返回的数组时遇到问题。我想用一张桌子来保存将从聊天中过滤掉的坏词。
$msg = "some user input, with a few bad words."; //(not putting bad words here, just an example)
$words = $this->db->query("SELECT * FROM tblBadWords")->result_array();
$replacement = "@#$@#";
$msg = str_ireplace($words, $replacement, $msg); //<--nothing happens
$word = str_ireplace($words[0], $replacement, $msg); //<--nothing happens
$word = str_ireplace($words[1], $replacement, $msg); //<--filters first word in table only
我究竟做错了什么?请注意,我是 php 数据库编码的新手。