Eccomi, e grazie per l'aiuto ma se lo porto nella classe non funziona ti posto la funzione originale:
class KeywordPosition
{
var $url='';
var $keywords='';
var $maxPosition=1;
function KeywordPosition($url,$keywords,$maxPosition)
{
$url=str_replace('http://www.','',$url);
//$url=str_replace('www.','',$url);
$this->url=$url;
$this->keywords=$keywords;
if($maxPosition<1)
$maxPosition=1;
$this->maxPosition=$maxPosition;
}
function GetPosition()
{
if(isset($this->url) && isset($this->keywords))
{
$make_url = 'http://www.google.it/search?hl=it&q=' . urlencode($this->keywords) . '&start=';
$index=0; // counting start from here
$found=false; // set this flag to true when position found
for ($page = 0; $page < $this->maxPosition; $page++)
{
if($found==true) // break the loop when position found
break;
$readPage = fopen($make_url . $page . 0 ,'r');
$contains = '';
if ($readPage)
{
while (!feof($readPage))
{
$buffer = fgets($readPage, 4096);
$contains .= $buffer;
}
fclose($readPage);
}
$results = array();
preg_match_all('/a href="([^"]+)" class=l.+?>.+?<\/a>/',$contains,$results);
foreach ($results[1] as $link)
{
$link = preg_replace('(^http://|/$)','',$link);
$index=$index+1;
if (strlen(stristr($link,$this->url))>0)
{
$found=true;
echo"$link";
$link_a[ ]="$link";
break;
}
}
}
if($found==true)
return $index;
else
return -1;
}
return -1;
}
}

il problema è che se vado a visualizzare la var link me la visualizza se la inserisco nell'array l'array è vuoto. Non riesco a capire perchè!!!