Google api provides a way to embed google search results in our web page. Visit the following link to sign up for an api key and place it in the code to get the search results. http://code.google.com/apis/customsearch/v1/getting_started.html
//Name this class as class.googlesearch.php
<?php
class googlesearch
{
/*start of returnresults function*/
function returnresults($search,$startv,$key)
{
$search = trim($search);
/* trim whitespace at start and end to ensure no empty query is submitted*/
$search=html_entity_decode($search);
if(strlen($search) == 0) {
echo "<p>Error: empty search</p>";
}
else {
$get = file_get_contents("http://ajax.googleapis.com/ajax/services/search/web?v=1.0