use Currency\CurrencyExchangeRate; // Fetch exchange rate between USD and EUR $exchangeRate = CurrencyExchangeRate::fetchExchangeRate('USD', 'EUR'); echo $exchangeRate;
use Currency\CurrencyFormatter; // Format currency amount in USD for en_US locale $currencyAmount = CurrencyFormatter::formatCurrency(1000, 'USD', 'en_US'); echo $currencyAmount; // Output: $1,000.00
use Currency\CurrencyConverter; // Convert 1000 USD amount to EUR $convertedAmount = CurrencyConverter::convertCurrency(1000, 'USD', 'EUR'); echo $convertedAmount; // Output: 859.90In conclusion, the Currency package library in PHP provides an easy way to manage currency-related operations like fetching exchange rate, formatting currency amount, and converting currency amount. It is widely used in e-commerce applications and financial systems.