PHP code example of rixafy / currency

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

    

rixafy / currency example snippets


$eur = $this->currencyFacade->getByCode('EUR'); // returns Currency instance
$usd = $this->currencyFacade->getByCode('USD'); // returns Currency instance

$eur->convertFrom($usd, 100); // converts 100 USD to EUR, returns float
$eur->convertTo($usd, 100); // converts 100 EUR to USD, returns float

echo $this->currencyFacade->getByCode('USD')->formatToNumber(45.54); // returns 45.54
echo $this->currencyFacade->getByCode('EUR')->formatToNumber(45.54); // returns 45,54
echo $this->currencyFacade->getByCode('USD')->formatToString(45.54); // returns $45.54
echo $this->currencyFacade->getByCode('EUR')->formatToString(45.54); // returns 45,54 €