Triby
Código PHP:
Ver original<?php
function romanNumber($number) {
if($number < 0 || $number > 10000)
return '* error *';
$spanv = '<span style="border-top:1px #000 solid;">V</span>';
$spanx = '<span style="border-top:1px #000 solid;">X</span>';
if($number == 10000)
return $spanx;
// Unidades
1 => array('', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'), // Decenas
2 => array('', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'), // Centenas
3 => array('', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'), // Millares
4 => array('', 'M', 'MM', 'MMM', 'MV', $spanv, $spanv . 'M', $spanv . 'MM', $spanv . 'MMM', 'M' . $spanx), );
$rn = '';
$number = (string)$number;
for($i = $len; $i > 0; $i--)
$rn .= $romans[$i][$number[$len - $i]];
return $rn;
}
// EOF;