1. Go to this page and download the library: Download cable8mm/n-format 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/ */
use Cable8mm\NFormat\Drivers\Contracts\OrdinalDriver;
final class EnUsOrdinalDriver implements OrdinalDriver
{
public function spellOut(int $number): string
{
return match ($number) {
1 => 'first',
2 => 'second',
default => $number.'th',
};
}
}
NFormat::registerOrdinal('en_US', new EnUsOrdinalDriver);
NFormat::ordinalSpellOut(2, 'en_US'); // second
use Cable8mm\NFormat\Drivers\Contracts\CurrencyDriver;
final class UsdCurrencyDriver implements CurrencyDriver
{
public function currencySpellOut(string $formatted): string
{
return $formatted.' dollars';
}
public function roundDigits(): array
{
return [3 => -1, 4 => -2, 5 => -2];
}
}
NFormat::registerCurrency('USD', new UsdCurrencyDriver);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.