PHP code example of aeunius / laravel-numero-a-letras
1. Go to this page and download the library: Download aeunius/laravel-numero-a-letras 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/ */
aeunius / laravel-numero-a-letras example snippets
use Aeunius\NumeroALetras\Facades\NumeroALetras;
NumeroALetras::convertir(1250.50);
// "MIL DOSCIENTOS CINCUENTA CON 50/100 SOLES"
NumeroALetras::moneda('USD')->convertir(99.90);
// "NOVENTA Y NUEVE CON 90/100 DÓLARES AMERICANOS"
numero_a_letras(1250.50);
// lo mismo que NumeroALetras::convertir()
// config/numero-a-letras.php
return [
'moneda' => 'PEN', // 'USD', 'EUR' o una clase que implemente Contracts\Moneda
'mayusculas' => true,
'formato_centavos' => 'fraccion', // o 'texto'
'conector' => 'con', // o 'y'
];
use Aeunius\NumeroALetras\Support\Conversor;
$conversor = new Conversor;
$conversor->convertir(1250.50); // "MIL DOSCIENTOS CINCUENTA CON 50/100 SOLES"
$conversor->convertir('1250.50'); // lo mismo
$conversor->convertir(0.5); // "CERO CON 50/100 SOLES"
$conversor->convertir(21); // "VEINTIUNO CON 00/100 SOLES"
$conversor->convertir(21000); // "VEINTIÚN MIL CON 00/100 SOLES"
$conversor->convertir(1000000); // "UN MILLÓN CON 00/100 SOLES"
$conversor->moneda('USD')->convertir(99.90);
// "NOVENTA Y NUEVE CON 90/100 DÓLARES AMERICANOS"
$conversor->soles()->minusculas()->convertir(5);
// "cinco con 00/100 soles"
$conversor->soloTexto()->convertir(21);
// "VEINTIUNO"
$conversor->formatoCentavos('texto')->convertir(1250.50);
// "MIL DOSCIENTOS CINCUENTA SOLES CON CINCUENTA CÉNTIMOS"
$conversor->conector('y')->convertir(1858.59);
// "MIL OCHOCIENTOS CINCUENTA Y OCHO Y 59/100 SOLES"
use Aeunius\NumeroALetras\Contracts\Moneda;
final class LibraEsterlina implements Moneda
{
public function singular(): string { return 'libra esterlina'; }
public function plural(): string { return 'libras esterlinas'; }
public function femenina(): bool { return true; }
public function centavoSingular(): string { return 'penique'; }
public function centavoPlural(): string { return 'peniques'; }
}
$conversor->moneda(new LibraEsterlina)->formatoCentavos('texto')->convertir(21.01);
// "VEINTIUNA LIBRAS ESTERLINAS CON UN PENIQUE"
use Aeunius\NumeroALetras\Support\Palabras;
Palabras::deEntero(1250); // "mil doscientos cincuenta"
Palabras::deEntero(21, apocope: true); // "veintiún", delante de un sustantivo
Palabras::deEntero(200201, femenino: true); // "doscientas mil doscientas una"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.