PHP code example of antonienko / money-formatter

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

    

antonienko / money-formatter example snippets


use antonienko\MoneyFormatter\MoneyFormatter;
use Money\Currency;
use Money\Money;

$some_euros   = new Money(300005, new Currency('EUR'));
$some_dollars = new Money(300005, new Currency('USD'));
$mf = new MoneyFormatter('fr_FR');

$amount = $mf->toFloat($some_euros); //$amount will be (float)3000.05

$french_formatted = $mf->toString($some_euros); //$french_formatted will be '3 000,05 €'

$just_symbol = $mf->toSymbol($some_dollars); //$just_symbol would be '$'

$full_symbol = $mf->toSymbol($some_dollars, false); //$full_symbol would be '$US'

$position = $mf->getSymbolPosition($some_euros); //position would be MoneyFormatter::SYMBOL_POSITION_RIGHT