PHP code example of baffouradu / currency-convertor

1. Go to this page and download the library: Download baffouradu/currency-convertor 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/ */

    

baffouradu / currency-convertor example snippets




use BaffourAdu\CurrencyConvertor\Convertor;

//free.currencyconverterapi.com/free-api-key
$currencyConvertor = new Convertor('xxxxxxxxxxxxxxxxxxxxxx');

/**
 * Get the exchange rate between two currencies
*/
echo $currencyConvertor->from('CAD')
                    ->to('GHS')
                    ->getRate();

/**
 * Convert an amount from one currency to another
*/
echo $res = $currencyConvertor->from('CAD')
                    ->to('GHS')
                    ->amount(150.00)
                    ->convert();