Php 在opencart中将印度卢比转换为美元
如何在opencart中将印度卢比转换为美元。我试过下面的代码Php 在opencart中将印度卢比转换为美元,php,arrays,opencart,json,Php,Arrays,Opencart,Json,如何在opencart中将印度卢比转换为美元。我试过下面的代码 $json_from = number_format($item_total, 2, '.', ''); $url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD"; $jsons = @file_get_contents($url); $json_data = json_decode($jsons
$json_from = number_format($item_total, 2, '.', '');
$url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD";
$jsons = @file_get_contents($url);
$json_data = json_decode($jsons, true);
$to_cur = $json_data['results'][0];
$data['PAYMENTREQUEST_0_ITEMAMT'] = $to_curr;
$data['PAYMENTREQUEST_0_AMT'] = $to_curr;
你对api的url调用不正确,你需要像这样调用
$json_from = number_format($item_total, 2, '.', '');
$url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD";
$jsons = @file_get_contents($url);
$json_data = json_decode($jsons, true);
$to_cur = $json_data['results'][0];
$data['PAYMENTREQUEST_0_ITEMAMT'] = $to_curr;
$data['PAYMENTREQUEST_0_AMT'] = $to_curr;
$url = "http://rate-exchange.appspot.com/currency?from=INR&to=USD";
从那里,您将获得将印度卢比转换为美元的转换率,就像现在给出的0.0168728
和您的金额的倍数一样,以获得预期结果
$json_from = number_format($item_total, 2, '.', '');
$url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD";
$jsons = @file_get_contents($url);
$json_data = json_decode($jsons, true);
$to_cur = $json_data['results'][0];
$data['PAYMENTREQUEST_0_ITEMAMT'] = $to_curr;
$data['PAYMENTREQUEST_0_AMT'] = $to_curr;
旁注:您还可以将第三个参数传递为&q=4300
,直接从api获取转换后的值
$json_from = number_format($item_total, 2, '.', '');
$url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD";
$jsons = @file_get_contents($url);
$json_data = json_decode($jsons, true);
$to_cur = $json_data['results'][0];
$data['PAYMENTREQUEST_0_ITEMAMT'] = $to_curr;
$data['PAYMENTREQUEST_0_AMT'] = $to_curr;
您的输入是什么?你期望得到什么结果?@Rikesh:看到这个问题了吗?这个方法正确吗<代码>$url=”http://rate-exchange.appspot.com/currency?from=INR&to=USD&q=$json_from”代码>是,它是正确的。我已经更新了我的演示,请检查。
$json_from = number_format($item_total, 2, '.', '');
$url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD";
$jsons = @file_get_contents($url);
$json_data = json_decode($jsons, true);
$to_cur = $json_data['results'][0];
$data['PAYMENTREQUEST_0_ITEMAMT'] = $to_curr;
$data['PAYMENTREQUEST_0_AMT'] = $to_curr;