我仍然试图在PHP中作为一种语言来解决此操作,我有一个自定义错误消息array()
我想把我的函数回声放到自定义错误{{1}我有消息。
请提前帮助谢谢......
array()
是否可以像这样返回:
$msg = array();
$spam = "hate partisan party kill maim murder violence love sex fight beat assasinate thug steal sell bribe protest baricade bullets militia fear ";
$spam_array = explode(" ",$spam);
$isSpam = isSpam($_POST['msgTextArea'], $spam_array);
function isSpam($content, $spamList)
{
foreach($spamList as $badWord) {
if(stripos($content, $badWord) !== false) {
$msg['new'] = return "Spam filter rejects your message! try again.";
}
答案 0 :(得分:2)
我不确定我理解你,但如果我这样做你只需要用“返回”代替“echo”...
答案 1 :(得分:0)
编辑:根据您提供的内容:
function isSpam($content = false, $spamList = "hate,partisan,party,kill,maim,murder,violence,love,sex,fight,beat,assasinate,thug,steal,sell,bribe,protest,baricade,bullets,militia,fear")
{
// You can feed the string or an array
$spam_array = (!is_array($spamList))? explode(",",$spamList) : $spamList;
// Loop through the list and match
foreach($spam_array as $badWord) {
if(stripos($content, $badWord) !== false)
return "Spam filter rejects your message! try again.";
}
}
$msg['new'] = isSpam($_POST['msgTextArea']);