<html>
<head>
<title>test</title>
</head>
<body>
<?php
function urban($w) {
//get the source of the page
$s = file_get_contents("http://www.urbandictionary.com/define.php?term=".str_replace(chr(32),chr(43),$w));
//check if the word was found
if (strpos($s,"isn't defined")) { return "No entry was found."; }
else {
//perform a regex match to grab the definition
preg_match_all("/<p>(.*?)<\/p>/i",$s,$matches);
//return the definition
return strip_tags($matches[1][0]);
}
}
if(isset($_POST['submit'])) echo urban($_POST['submit']);
else
echo urban("wrong");
?>
<form action = '<?php $_SERVER['PHP_SELF'] ?>' method = 'post'>
<input type = 'text' name = 'text' size="40" value='Put your magic word in here' >
<input type = 'submit' name='submit' value='Urban me!'>
</form>
</body>
</html>