繁体   English   中英

从 xml + php 转换货币

[英]convert currency from xml + php

我有一个每日货币的 xml 来源http://www.tcmb.gov.tr/kurlar/today.xml

我需要对门户进行货币可选搜索。 如何获取特定数据并从 xml 源转换? :/

我有一个搜索表格:

  • 价格输入
  • 货币列表框(欧元、美元)

我需要将表格中的值转换为产品价格货币。

欣赏帮助!! 谢谢!!!

您可以像这样读取转换率:

<?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];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM