I have the following code:
$search = trim($_GET["q"]);
$url = "http://www.google.com/search?meta=&q=" . $search;
$gdymresult = file_get_contents($url);
if ($gdymresult != false) {
if (preg_match_all("/class\\=spell\\>(.*?)\\<\\/a\\>/i", $gdymresult, $matches)) {
$gdymresult = $matches[1][0];
}
else {
// the spelling is correct
}
}
else {
// error downloading
}
And with the preg_match_all
, I want to get the value of the i inside the spell class tag, which contains the suggested word with correct spelling. But this always returns false, so it means that preg_match_all
has no occurrencies.