TechniqueUse PEAR's Numbers_Roman class to convert back and forth: <?php $number = 43; $numeral = Numbers_Roman::toRoman ($number); $number = Numbers_Roman::toNumber ($numeral); print "$number in Roman Numerals is $numeral"; ?> CommentsThe Numbers_Roman module works only with Roman numerals greater than 0 up to and including 3,999 (0 < x <= 3,999). This is because Romans didn't deal with negative numbers and zero, and 5000 (which is needed to display 4,000) uses a symbol that is not in the ASCII character set. The Numbers_Roman module also provides an isRoman() method, which will return true if the first argument is a valid Roman numeral, and will return false otherwise . |