below function used to convert one currency to another
function get_conversion($cur_from,$cur_to){
if(strlen($cur_from)==0){
$cur_from = "USD";
}
if(strlen($cur_to)==0){
$cur_from = "PHP";
}
$host="finance.yahoo.com";
$fp = @fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp)
{
$errorstr="$errstr ($errno)
\n";
return false;
}
else
{
$file="/d/quotes.csv";
$str = "?s=".$cur_from.$cur_to."=X&f=sl1d1t1ba&e=.csv";
$out = "GET ".$file.$str." HTTP/1.0\r\n";
$out .= "Host: www.yahoo.com\r\n";
$out .= "Connection: Close\r\n\r\n";
@fputs($fp, $out);
while (!@feof($fp))
{
$data .= @fgets($fp, 128);
}
@fclose($fp);
@preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $data, $match);
$data =$match[2];
$search = array ("'
No comments:
Post a Comment