Wednesday, November 11, 2009

Find how many number of result of your site on google

<?php
/* return result number */
function get_google_results($domain = 'vijayjoshi.org')
{
// get the result content
$content = file_get_contents('http://www.google.com/search?q=site:'.$domain);

// parse to get results
$result = get_match('/Results <b>(.*)from/isU',$content);

// echo $result;

// split the results
$split1 = explode('of about',$result);

// return result
return $split1[1] ? strip_tags($split1[1]) : 0;
}

/* helper: does the regex */
function get_match($regex,$content)
{
preg_match($regex,$content,$matches);
return $matches[1];
}

/* do it! */
echo 'vijayjoshi.org: '.get_google_results('vijayjoshi.org'); // 164
//echo 'Philogy.com: '.get_google_results('philogy.com'); // 164
?>

Laravel Interview questions and answers

1. What is Laravel Laravel is free open source “PHP framework” based on MVC Design Pattern . It is created by Taylor Otwell. Laravel pro...