PHP code example of sfadless / number-to-string-converter
1. Go to this page and download the library: Download sfadless/number-to-string-converter 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/ */
sfadless / number-to-string-converter example snippets
use Sfadless\NumberToStringConverter\Language\Russian\RussianLanguageFactory;
use Sfadless\NumberToStringConverter\NumberToStringConverter;
$factory = new RussianLanguageFactory();
$russianLanguage = $factory->create();
$converter = new NumberToStringConverter($russianLanguage);
$converter->convert(33.27); //тридцать три рубля двадцать семь копеек
use Sfadless\NumberToStringConverter\Language\Russian\Output\Output;
use Sfadless\NumberToStringConverter\Language\Russian\Output\OutputVariable;
$variable = new OutputVariable('i_short_curency', function (Output $output) {
return mb_substr($output->getInteger()->getCurrency(), 0, 3);
});
$template = '%i_value% %i_short_curency%';
$converter->convert(12, ['template' => $template, 'variables' => [$variable]]); // 12 руб
use Sfadless\NumberToStringConverter\Language\Russian\Currency;
use Sfadless\NumberToStringConverter\Language\Russian\Declension\Declension;
$currency = new Currency(
new Declension('доллар', 'доллара', 'долларов', Declension::GENDER_M),
new Declension('цент', 'цента', 'центов', Declension::GENDER_M)
);
$converter->convert(3.05, ['currency' => $currency]); //три доллара пять центов
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.