簡體   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