<?php
if(!$_GET[l])
echo '<a href="?l=en">English</a> - <a href="?l=ru">Русский</a> - <a href="?l=other">Other...</a>';
elseif($_GET[l]=='other')
echo '<form method="get">
Language:
<input type="text" autocomplete="on" name="l">
<input type="submit" value="GO">
</form>';
else{
echo '<form method="get">
<input type="hidden" name="l" value="'.url_encode($_GET[l]).'">
Question:
<input type="text" autocomplete="on" name="q">
<input type="submit" value="GO">
</form>';
if($_GET[q]){
$l=url_encode($_GET[l]);
$q=url_encode($_GET[q]);
$xml=file_get_contents('http://google.com/complete/search?output=toolbar&hl='.$l.'&q='.$q);
$str=str_replace(array('<toplevel>', '</toplevel>', '<CompleteSuggestion>', '</CompleteSuggestion>', '<suggestion data="', '/>'), '', $xml);
$array=explode('"', substr($str, 0, -1));
$i=0;
foreach($array as $val){
if($i>0) echo '<br>';
echo $val;
$i++;
}
}
}
?>