use Money\Currency; $usd = new Currency('USD');
use Money\Money; $amount = new Money(1000, $usd);
$newAmount = $amount->add(new Money(500, $usd)); echo $newAmount->getAmount(); // output: 1500
use Money\Exchange\ReversedCurrenciesExchange; use Money\Exchange\RatioExchange; use Money\Formatter\IntlMoneyFormatter; use Money\Money; $usd = new Currency('USD'); $eur = new Currency('EUR'); $exchange = new RatioExchange(1.15); $reversedExchange = new ReversedCurrenciesExchange($exchange); $money = new Money(1000, $usd); $convertedMoney = $reversedExchange->quote($money, $eur); $formatter = new IntlMoneyFormatter( new \NumberFormatter('en_US', \NumberFormatter::CURRENCY), $eur ); echo $formatter->format($convertedMoney); // output: €869,57This converts $10.00 in USD to €8.70 in EUR using an exchange rate of 1.15. A formatter is used to format the result as a string with the Euro symbol. Overall, the PHP Currency Model is a powerful tool for handling currencies and money in PHP, and there are several library packages available that provide this functionality.