<?php class Kurlar{ function Donustur($miktar,$bundan,$buna){ $html= implode("",file('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml')); preg_match("/<Cube currency='".$bundan."' rate='(.*?)'\/>/si",$html,$p1); preg_match("/<Cube currency='".$buna."' rate='(.*?)'\/>/si",$html,$p2); if(($bundan) === "EUR"){ return $p2[1]*($miktar); }elseif(($buna) === "EUR"){ return 1/$p1[1]*($miktar); }else{ return $p2[1]*(1/$p1[1])*($miktar); } } } $kur = new Kurlar(); echo $kur->Donustur(1, 'USD', 'TRY'); ?>
Çıktısı
4.474492827434