Code: Select all
<?PHP
fwrite(STDOUT, "Enter a word to look up: ");
$term = fgets(STDIN);
if(!$term) {
die('Error: Enter a word to look up!');
$s = file_get_contents("http://www.urbandictionary.com/define.php?term=".urlencode($term)."");
if(strpos($s, "isnt defined")) {
die("Definition not found");
}
else {
preg_match("/<p>(.*?)<\/p>/",$s, $match);
echo html_entity_decode(strip_tags($match[0]));
}
?>only use it in the CLI




