1. Go to this page and download the library: Download tal7aouy/currency library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tal7aouy / currency example snippets
use Tal7aouy\Currency;
Currency::convert()
->from('USD')
->to('EUR')
->get();
use Tal7aouy\Currency;
Currency::convert()
->from('USD')
->to('EUR')
->amount(50)
->get();
use Tal7aouy\Currency;
Currency::convert()
->from('USD')
->to('EUR')
->date('2019-08-01')
->get();
use Tal7aouy\Currency;
Currency::convert()
->from('USD')
->to('EUR')
->round(2)
->get();
use Tal7aouy\Currency;
Currency::convert()
->from('BTC')
->to('ETH')
->source('crypto')
->get();
use Tal7aouy\Currency;
Currency::rates()
->latest()
->symbols(['USD', 'EUR', 'EGP']) //An array of currency codes to limit output currencies
->base('GBP') //Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
->amount(5.66) //Specify the amount to be converted
->round(2) //Round numbers to decimal places
->source('ecb') //Switch data source between forex `default`, bank view or crypto currencies.
->get();
use Tal7aouy\Currency;
Currency::rates()
->historical('2020-01-01') //`YYYY-MM-DD` Required date parameter to get the rates for
->get();
// ['USD' => 1.1185, ...]
Currency::rates()
->historical('2021-03-30')
->source('crypto')
->get();
// ['BTC' => 2.0E-5, ...]
use Tal7aouy\Currency;
Currency::rates()
->timeSeries('2021-05-01', '2021-05-02') //`YYYY-MM-DD` Required dates range parameters
->symbols(['USD']) //[optional] An array of currency codes to limit output currencies
->base('GBP') //[optional] Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
->amount(5.66) //[optional] Specify the amount to be converted (default: 1)
->round(2) //[optional] Round numbers to decimal places
->source('ecb') //[optional] Switch data source between forex `default`, bank view or crypto currencies.
->get();
/**
[
'2021-05-01' => [
"USD" => 1.201995
],
'2021-05-02' => [
"USD" => 1.2027
]
]
*/
use Tal7aouy\Currency;
Currency::rates()
->fluctuations('2021-03-29', '2021-04-15') //`YYYY-MM-DD` Required dates range parameters
->symbols(['USD']) //[optional] An array of currency codes to limit output currencies
->base('GBP') //[optional] Changing base currency (default: EUR). Enter the three-letter currency code of your preferred base currency.
->amount(5.66) //[optional] Specify the amount to be converted (default: 1)
->round(2) //[optional] Round numbers to decimal places
->source('ecb') //[optional] Switch data source between forex `default`, bank view or crypto currencies.
->get();
/**
[
'USD' => [
"start_rate" => 1.376454,
"end_rate" => 1.37816,
"change" => -0.001706,
"change_pct" => -0.001239
]
]
*/
use Tal7aouy\Currency;
Currency::convert()
->from('USD')
->to('EUR')
->amount(20)
->throw()
->get();