http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?seo'); //sanitize query input $keys = filter_var($_SERVER['QUERY_STRING'], FILTER_SANITIZE_STRING); //retrieve autocomplete data $contentstring = @file_get_contents("http://google.com/complete/search?output=toolbar&q=".urlencode($keys)); if(!$contentstring) die('no content retrieved'); //load xml string in simplexml $content = @simplexml_load_string($contentstring ); if(!$content) die('no xml'); //create table with links echo ""; //get the suggestion attributes foreach($content->CompleteSuggestion as $c) { //nb. cast as string $term = (string) $c->suggestion->attributes()->data; //if traffic data is missing ... $traffic = ''; if(isset($c->num_queries)) $traffic = (string) $c->num_queries->attributes()->int; //output the data as new queries for a walkthrough echo '" ; } echo "
'.$term.''.$traffic . "
"; //destroy xml object unset($content); ?>