Tuesday, February 13, 2007

ParseYahooRes

function ParseYahooRes($str)

--
Return Value: False if $str == Null String.
0(zero) if no search result is found.
GetNumber($s) if success.

* The GetNumber($s) function removes commas from a string and returns as an Integer.

--

function ParseYahooRes($str){
if ($str=="")
return false;

$s=explode("

Search Results

",$str,2);
if (count($s)==1)
$s=explode("

Directory Results

",$str,2);
$s=$s[1];

$s=explode(" of about ",$s,2);
if (count($s)==1)
return 0; // No results
$s=$s[1];
$s=explode(" ",$s,2);
$s=$s[0];
echo '*'.$s.'*';
return $this->GetNumber($s);
}


No comments: