php从mysql数据库屏蔽单词
我需要在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以从blocked_words表生成一个数组并像上面提到的代码一样使用它,
或者
可能你认为你想要的是类似于
检查行数是否为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
and check whether row count is 0 or not for determining whether it is blocked word?
我想我无法解释,但我已经从另一篇文章的 stackoverflow 答案中完成了我的要求,
这就是我所要求的
,我将表“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
by this i got all words from table 'blocked' into $blocked_words, now i can use it further
Thanks