开发者

convert currency from xml + php

开发者 https://www.devze.com 2022-12-11 11:28 出处:网络
I have an xml source for daily currency http://www.tcmb.gov.tr/kurlar/today.xml and i need to make a currency optional search for a portal. how can I get a 开发者_StackOverflow中文版specific data an

I have an xml source for daily currency http://www.tcmb.gov.tr/kurlar/today.xml

and i need to make a currency optional search for a portal. how can I get a 开发者_StackOverflow中文版specific data and convert from xml source? :/

i have a search form with:

  • price input
  • currency list box (euro, dollar)

and I need to convert the value from form for products price currency.

Appreciate helps!! thanks!!!


You can read the conversion rate like this:

<?php   

$x = simplexml_load_file('http://www.tcmb.gov.tr/kurlar/today.xml');

// Use GBP as an example
$code = 'GBP';

$nodes = $x->xpath('//Currency[@CurrencyCode="' . $code . '"]');

echo 'Buying Rate for ' . $code . 'is ' . (string)$nodes[0]->BanknoteBuying;


?>


$site = file_get_contents("http://www.tcmb.gov.tr/kurlar/today.xml"); 
preg_match_all("'EURO</CurrencyName><ForexBuying>(.*)</ForexBuying><ForexSelling>(.*)<CrossRateOther>(.*)<'U", $site, $durum);
preg_match_all("'POUND STERLING</CurrencyName><ForexBuying>(.*)</ForexSelling>(.*)<CrossRateOther>(.*)<'U", $site, $GBP);
$tl     = $durum[1][0]; 
$dolar  = $durum[3][0];
0

精彩评论

暂无评论...
验证码 换一张
取 消