Skip to content

Instantly share code, notes, and snippets.

View arnoldobr's full-sized avatar
💭
I may be slow to respond.

Arnoldo Briceño arnoldobr

💭
I may be slow to respond.
View GitHub Profile
@arnoldobr
arnoldobr / num2texto.php
Last active May 5, 2023 18:55
Convierte números en texto.
<?php
function letras($n){
$cent = ['', 'ciento', 'doscientos', 'trescientos', 'cuatrocientos', 'quinientos', 'seiscientos',
'setecientos', 'ochocientos', 'novecientos'];
$dec = [ '', '', '', 'treinta', 'cuarenta', 'cincuenta', 'sesenta', 'setenta', 'ochenta', 'noventa' ];
$uni = [ '', ' y un', ' y dos', ' y tres', ' y cuatro', ' y cinco', ' y seis', ' y siete', ' y ocho', ' y nueve';
for ($i = 0; $i < 100; $i++){
$num[$i] = $dec[intdiv($i, 10)] . $uni[$i % 10];
}