PHP code example of indibeast / currency-formatter

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

    

indibeast / currency-formatter example snippets


 $price = new Currency\Price(3000,'LKR');
 $price->pretty();// Rs 3,000.00

  $price = new Currency\Price(3000,'LKR',['show_decimal' => false,'seperator' => ',']);
  $price->pretty();// Rs 3,000
 

  $currency = new Price(1,'USD');
  $currency->setConverter(new OpenExchangeConverter('app_id'));// Pass true as second parameter if you are having an enterprise APP_ID.
  $currency->convert('LKR') // This will convert U.S Dollars to Sri Lankan Rupees
 

  class FixedConverter implements ConverterInterface{

     /**
      * @return float
      */
     public function getConversionRate($code,$to)
     {
         return 1;
     }
  }