1. Go to this page and download the library: Download xdemonme/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/ */
xdemonme / currency example snippets
use AmrShawky\Currency;
$accessKey = 'YOUR_API_ACCESS_KEY';
Currency::convert()
->setAccessKey($accessKey)
->from('USD')
->to('EUR')
->get();
use AmrShawky\Currency;
$accessKey = 'YOUR_API_ACCESS_KEY';
Currency::rates()
->setAccessKey($accessKey)
->live()
->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 AmrShawky\Currency;
$accessKey = 'YOUR_API_ACCESS_KEY';
Currency::rates()
->setAccessKey($accessKey)
->historical('2020-01-01') //`YYYY-MM-DD` Required date parameter to get the rates for
->get();
// ['USD' => 1.1185, ...]
Currency::rates()
->setAccessKey($accessKey)
->historical('2021-03-30')
->source('crypto')
->get();
// ['BTC' => 2.0E-5, ...]
use AmrShawky\Currency;
$accessKey = 'YOUR_API_ACCESS_KEY';
Currency::rates()
->setAccessKey($accessKey)
->timeFrame('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 AmrShawky\Currency;
$accessKey = 'YOUR_API_ACCESS_KEY';
Currency::rates()
->setAccessKey($accessKey)
->change('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
]
]
*/