【发布时间】:2014-07-02 04:59:49
【问题描述】:
我正在尝试使用http://www.webservicex.com/CurrencyConvertor.asmx?WSDL 的网络服务。 我可以在输入两种货币时转换金额,即“NZD”“GBP”等。但我需要有两个下拉框来获取所有货币代码并将它们作为选项放入。我不知道如何获得这些货币代码。谢谢你
php 的代码是
/* Get the values for the amount and currencies */
$amount = $_POST['amount'];
$currency1 = $_POST['currency1'];
$currency2 = $_POST['currency2'];
// Set the url for the webservice.
$wsdl="http://www.webservicex.com/CurrencyConvertor.asmx?WSDL";
// Make soap client.
$client = new SoapClient( $wsdl );
// Set up the parameters
$country=array();
// Set the country variable to the country codes.
$country['FromCurrency']= $currency1;
$country['ToCurrency'] = $currency2;
// Use the client to run the required operation and receive a response
$result = $client->ConversionRate($country);
// Print the results.
print("<br /> The exchange rate from <b>".$country['FromCurrency']."</b> to <b>".$country['ToCurrency']."</b> is: <b>". $result->ConversionRateResult)."</b><br />";
}
?>
在 html 中,我有两个选择框,我需要用国家代码(“NZD”、“GBP”等)填充它们,它们将是 currency1 和 currency2 变量。我想从 webservicex 获取这些货币代码作为数组或我可以用来填充选择框的东西。
【问题讨论】:
-
分享您的代码到目前为止,您需要国家代码或货币代码吗?
-
-1 不是一个真正的问题。 Learn how to ask