1

誰かが私に解決策を提供できますか?Paypalに渡す前に通貨AEDをUSDに変換する方法。

4

2 に答える 2

2

あなたは単にGoogleを使うことができます

試す

var_dump(simpleConvert("AED","USD",1));

出力

array
  '1.000000' => string '0.272257' (length=8)

使用する機能

function simpleConvert($from,$to,$amount)
{
    $content = file_get_contents('https://www.google.com/finance/converter?a='.$amount.'&from='.$from.'&to='.$to);

     $doc = new DOMDocument;
     @$doc->loadHTML($content);
     $xpath = new DOMXpath($doc);

     $result = $xpath->query('//*[@id="currency_converter_result"]/span')->item(0)->nodeValue;
     return $result;
}
于 2012-10-07T14:41:02.937 に答える
0

このコードを簡単に追加できます。

<?php

function convertCurrency($amount, $from, $to){
$data = file_get_contents("https://www.google.com/finance/converter?   a=$amount&from=$from&to=$to");
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1]);
return number_format(round($converted, 3),2);
}
echo convertCurrency("10", "AED", "USD");

?>
于 2016-05-27T09:50:22.807 に答える