我每天貨幣 http://www.tcmb.gov.tr/kurlar/today.xml換算貨幣從XML + PHP
XML源,我需要做一個門戶貨幣可選的搜索。我如何獲得特定數據並從xml源文件轉換? :/
我有一個搜索表單:
- 價格輸入
- 貨幣列表框(歐元,美元)
,我需要的價值從形式轉化爲產品價格貨幣。
鑑賞幫助!謝謝!!!
我每天貨幣 http://www.tcmb.gov.tr/kurlar/today.xml換算貨幣從XML + PHP
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;
?>
嗯,這就是酷什麼,所以我可以使$代碼動態從形式提交和使用數學動作:)謝謝... – 2009-11-17 13:25:44
$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];
對不起,真的不明白你想要做:( – Znarkus 2009-11-17 13:00:21