<?php
if( strlen($_POST['submit']) > 0 )
{
$google_root = 'google.com';
$keywords = str_replace(' ', '+', stripslashes($_POST['query']));
$buffer = file_get_contents('http://' . $google_root . '/search?hl=en&q=' . $keywords);
if( preg_match("/Results <b>[0-9]+<\/b> - <b>[0-9]+<\/b> of about <b>([^\.]+)<\/b> for/i", $buffer, $matches) )
{
echo "There were {$matches[1]} results found for " . str_replace('+', ' ', '"' . $keywords . '"');
}
else
{
echo 'No results were found';
}
}
else
{
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Keywords: <input type="text" name="query" value="" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
}
?>