Created
August 17, 2011 17:11
-
-
Save batuhan/1152044 to your computer and use it in GitHub Desktop.
Is offensive?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//checks if text contains any offensive words, returns boolean. | |
function is_offensive($text){ | |
$data = file_get_contents('http://www.wdyl.com/profanity?q='.$text); | |
$data = json_decode($data); | |
return $data->response; | |
} | |
//Example | |
$text = 'Fuck it, I'll watch some porn'; // will return true | |
#$text = 'Nevermind, I'll watch Mythbusters'; // should return false | |
if(is_offensive($text) === TRUE){ | |
echo 'contains some bad words!'; | |
}else{ | |
echo 'It\'s clean!'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment