Mega Code Archive

 
Categories / Php / Code Snippets
 

This is a currency convertor which allows a user to get the latest currency

conversions from Yahoo <? //our currencies $currency = array("Yen","US Dollars","German mark","french franc","Australian dollar"); //the various URLS for the currency conversions $conv[0]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=JPY&c=0'); $conv[1]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=USD&c=0'); $conv[2]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=DEM&c=0'); $conv[3]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=FRF&c=0'); $conv[4]=file('http://quote.yahoo.com/m5?a=1&s=GBP&t=AUD&c=0'); //loop through results for($i=0; $i<sizeof($conv); $i++) { $conv[$i] = join("",$conv[$i]); //parse out the relevant information $conv[$i] = ereg_replace(".*<table border=1 cellpadding=2 cellspacing=0>",'',$conv[$i]); $conv[$i] = ereg_replace("</table>.*",'',$conv[$i]); $conv[$i] = ereg_replace("</b>.*",'',$conv[$i]); $conv[$i] = ereg_replace(".*<b>",'',$conv[$i]); //display results echo "1 Pound(£) = ".$conv[$i]." ".$currency[$i]."<br>\n"; } ?>