I want to do an auto completion using Firefox's suggestions. Is it possible to call a php function while typing a keyword ? Is there any better way to do it?
 public function stealSearchGoogle(){ 
    $lang  = 'fr';
    $query = 'developeur';
    $url   = 'http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl=' . $lang . '&q=' . urlencode($query);
    $ch    = curl_init($url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1");
    $data = curl_exec($ch);
    curl_close($ch);
    $suggestions = json_decode($data, true);
    if ($suggestions) {
        //echo 'suggestions: ';
        foreach ($suggestions as $value) {
            return($value);
        }
    }
}