Skip to content

Instantly share code, notes, and snippets.

@cloudsben
Created December 6, 2012 06:06
Show Gist options
  • Save cloudsben/4222129 to your computer and use it in GitHub Desktop.
Save cloudsben/4222129 to your computer and use it in GitHub Desktop.
敏感词过滤
function checkUploadText($content)
{
$stoptext = file_get_contents($this->CI->config->item('stopword_file'));
$stoptext = str_replace("\n",'',$stoptext);
$stoptext = str_replace("\r",'',$stoptext);
$stopwords = array_map('strtolower',explode(',',$stoptext));
$content = strtolower($content);
$ret = array('ret'=>1,'word'=>'');
if($content!='')
foreach($stopwords as $row)
{
if(trim($row)!='')
{
if(strpos($content,$row)===false)
continue;
else
{
$ret = array('ret'=>0,'word'=>$row);
break;
}
}
}
return $ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment