carlos_belisario
Código PHP:
Ver original<?php
function romanNumber($number){
$romano=array("I","V","X","L","C","D","M","<span style='text-decoration: overline;'>V</span>","<span style='text-decoration: overline;'>X</span>","<span style='text-decoration: overline;'>L</span>","<span style='text-decoration: overline;'>C</span>","<span style='text-decoration: overline;'>D</span>","<span style='text-decoration: overline;'>M</span>"); $g=0;
for($x=count($nume)-1;$x>=0;$x--){ $num[$g]=$nume[$x];
$g++;
}
for($i=0;$i<count($num);$i++){ if($num[$i]>0 && $num[$i]<4){
$id=$i+$i;
for($k=0;$k<$num[$i];$k++)
$romanNumber=$romano[$id].$romanNumber;
}
elseif($num[$i]>3 && $num[$i]<9){
$id=$i+1;
if ($num[$i]<5){
$id=$id+$i;
$romanNumber=$romano[$id-1].$romano[$id].$romanNumber;
}
else{
$id=$id+$i;
$principio=$romano[$id];
$numero=$num[$i]-5;
for($l=1;$l<=$numero;$l++)
$principio.=$romano[$id-1];
$romanNumber=$principio.$romanNumber;
}
}
elseif($num[$i]==9 || $num[$i]==0){
$id=($i+1)*2;
if($num[$i]==9)
$romanNumber=$romano[$id-2].$romano[$id].$romanNumber;}
else
continue;
}
return $romanNumber;
}?>