Covert amount to US dollar via PHP and Yahoo Finance Rates

PHP function to Auto automatically convert and display dollar equivalent of your peso value.

Rates via Yahoo Finance, easy to use function, for everybody…

Read on…

CONST YAHOO_URL = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=%s%s=X';
function yahoo_convert($a,$from,$to){
   $fo = @fopen(sprintf(self::YAHOO_URL,$from,$to), 'r');
   if ($fo){
      $response = fgets($fo, 4096);
	fclose($fo);
	array = explode(',',$response);
	if(strval($array[1]) > 0) {
	   return strval($a)*strval($array[1]);
	}
   }
   return false;
}

To use

<?php
echo yahoo_convert(1,USD,PHP);
?>

For questions / help send me a message of just comment for help instructions…

6 Responses to “Covert amount to US dollar via PHP and Yahoo Finance Rates”

  1. stream says:

    I didn’t understand the concluding part of your article, could you please explain it more?

  2. which part of it you do not understand? well to start, this is a PHP function and using this should look like

    save it as a PHP for ex convert.php and run it to your server

    Did I answer that correctly? clearly?

  3. whicj part of it you do not understand? well to start, this is a PHP function and using this should look like

     

    save it as a PHP for ex convert.php and run it to your server

    Did I answer that correctly? clearly?

  4. Bruce says:

    I didn’t understand the concluding part of your article, could you please explain it more?

  5. Johnju says:

    I am not going to be original this time, so all I am going to say that your blog rocks, sad that I don’t have suck a writing skills

  6. Bingmj says:

    I really like when people are expressing their opinion and thought. So I like the way you are writing

Leave a Reply