用于货币转换的php脚本 [英] php script for currency conversion

查看:81
本文介绍了用于货币转换的php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个执行货币转换的php脚本。

I am looking for a php script that does currency conversion.

在哪里可以找到一个与codeigniter一起使用?

Where can I find one that works with codeigniter?

推荐答案

您可以使用以下代码轻松转换google转换货币。有关更多关于PHP中的货币转换库的信息,请点击这里 http://mydons.com/currency -conversion-library-in-codeigniter /

You can convert currency with google conversion easily with the below code. Read more about Currency Conversion library in PHP with google here http://mydons.com/currency-conversion-library-in-codeigniter/

public function getResult(){           
$result = file_get_contents($this->googleUrl);/* Convert the above result into Array */                           
$result = explode('"', $result);/* Right side text*/           
$convertedAmount = explode(' ', $result[3]);           
$conversion = $convertedAmount[0];           
$conversion = $conversion * $this->amount;          
$conversion = round($conversion, 2);//Get text for converted currency               
$rightText = ucwords(str_replace($convertedAmount[0],"",$result[3]));//Make right hand side string           

$rightText = $conversion.$rightText;/* Left side text*/           
$googleLeft = explode(' ', $result[1]);           
$fromAmount = $googleLeft[0];//Get text for converted from currency              

$fromText = ucwords(str_replace($fromAmount,"",$result[1])); //Make left hand side string           
$leftText = $this->amount." ".$fromText;             
return $leftText." = ".$rightText; 
}

这篇关于用于货币转换的php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆