angelAparicio
Código PHP:
Ver original<?php
define('CINCOMIL', '<span style="text-decoration: overline">V</span>'); define('DIEZMIL', '<span style="text-decoration: overline">X</span>');
function romanNumber($num){
$unidad = $num % 10;
$decena = ($num/10) % 10;
$centena = ($num/100) % 10;
$millar = ($num/1000) % 10;
0 => '', 1 => 'I', 2 => 'II', 3 => 'III', 4 => 'IV',
5 => 'V', 6 => 'VI', 7 => 'VII', 8 => 'VIII', 9 => 'IX'
);
0 => '', 1 => 'X', 2 => 'XX', 3 => 'XXX', 4 => 'XL',
5 => 'L', 6 => 'LX', 7 => 'LXX', 8 => 'LXXX', 9 => 'XC'
);
0 => '', 1 => 'C', 2 => 'CC', 3 => 'CCC', 4 => 'CD',
5 => 'D', 6 => 'DC', 7 => 'DCC', 8 => 'DCCC', 9 => 'CM'
);
0 => '', 1 => 'M', 2 => 'MM', 3 => 'MMM', 4 => 'M'.CINCOMIL,
5 => CINCOMIL, 6 => CINCOMIL.'M', 7 => CINCOMIL.'MM', 8 => CINCOMIL.'MMM', 9 => 'M'.DIEZMIL
);
$num = $array_millar[$millar] . $array_centenas[$centena] . $array_decenas[$decena] . $array_unidades[$unidad];
return $num;
}
?>