php从mysql数据库屏蔽单词

发布于 2024-12-19 06:43:44 字数 361 浏览 2 评论 0原文

我需要在 mysql 数据库中保存被阻止的单词列表,并使用下面的代码来阻止某些单词或电话号码...请帮忙举一个小例子。 谢谢

$blocked_words=array("word1" ,"word2","word3");  
$string_words=explode(" ", $_POST['text']);  
$phone_words=explode(" ", $_POST['phone']);  
$result = array_intersect($blocked_words, $string_words);  
$result_phone = array_intersect($blocked_words, $phone_words);

I need to save a list of blocked words in mysql database and use my below code to block some words or phone numbers... Please help with a little example.
Thanks

$blocked_words=array("word1" ,"word2","word3");  
$string_words=explode(" ", $_POST['text']);  
$phone_words=explode(" ", $_POST['phone']);  
$result = array_intersect($blocked_words, $string_words);  
$result_phone = array_intersect($blocked_words, $phone_words);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天冷不及心凉 2024-12-26 06:43:44

您可以从blocked_words表生成一个数组并像上面提到的代码一样使用它,

或者
可能你认为你想要的是类似于

"SELECT word FROM blocked_words WHERE word == $Phone_num"

检查行数是否为0来确定它是否被阻止的单词?

You can generate an array from the blocked_words table and use it like above code you mentioned,

Or
May be what you think you want is something similar to

"SELECT word FROM blocked_words WHERE word == $Phone_num"

and check whether row count is 0 or not for determining whether it is blocked word?

疯了 2024-12-26 06:43:44

我想我无法解释,但我已经从另一篇文章的 stackoverflow 答案中完成了我的要求,

这就是我所要求的

$blocked_words=array();
$q="select words from blocked";
$rs=mysql_query($q);
while($rd=mysql_fetch_object($rs))
{
$blocked_words[]=$rd->words;
}

,我将表“blocked”中的所有单词放入 $blocked_words,现在我可以使用它进一步

感谢

I think i was not able to explain, but i have completed my requirement from one of a stackoverflow answers from another post

here is what i was required

$blocked_words=array();
$q="select words from blocked";
$rs=mysql_query($q);
while($rd=mysql_fetch_object($rs))
{
$blocked_words[]=$rd->words;
}

by this i got all words from table 'blocked' into $blocked_words, now i can use it further

Thanks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文