PHP code example of msajko / money-formatter

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

    

msajko / money-formatter example snippets



  use Msajko\MoneySpellOut;

  //if you not using composer
  _LEFT));

  $amount='12.432,23';
  $money = new MoneySpellOut('de', $amount);
  echo 'DE: "'.$amount.'" => '.$money->get('€', '¢',' und').PHP_EOL;

  $amount='12.432,23 €';
  $money->setAmount($amount, 'it');
  $money->setCountrycode('it');
  echo 'IT: "'.$amount.'" => '.$money->get('€', '¢',' e').PHP_EOL;

  $amount='12 432,23 €';
  $money->setCountrycode('fr');
  $money->setAmount($amount, 'fr');
  echo 'FR: "'.$amount.'" => '.$money->get('€', '¢',' et').PHP_EOL;

  $amount='12.432,23 EUR';
  $money->setCountrycode('es');
  $money->setAmount($amount, 'es');
  echo 'ES: "'.$amount.'" => '.$money->get('€', '¢',' y').PHP_EOL;

  $amount='€12,432.23';
  $money->setCountrycode('gb');
  $money->setAmount($amount, 'gb');
  echo 'GB: "'.$amount.'" => '.$money->get('£', 'pence',' and').PHP_EOL;

  $amount='$12,432.23';
  $money->setCountrycode('us');
  $money->setAmount($amount, 'us');
  echo 'US: "'.$amount.'" => '.$money->get('$', '¢',' &').PHP_EOL;

  echo PHP_EOL;
  $money->setCountrycode('hr');
  echo 'HR(1): "'.$amount.'" => '.$money->get('kuna', 'lipa', ' i').PHP_EOL;
  //no spacing & php_intl independent
  echo 'HR(2): "'.$amount.'" => '.$money->getHr().PHP_EOL;

$amount=12432;
$nFormat = new NumberFormatter('de', NumberFormatter::SPELLOUT);
$nFormat->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%spellout-ordinal-feminine");

var_dump($nFormat->format($amount));