PHP - Number: Converting Numbers into Roman NumeralsTag: number, convert, roman numerals Category: PHP Application, PHP Basicpost: 16 Mar 2008 read: 246 PHP Number Tips - Part 6: If you want to print a number as a Roman Numeral, you only have to use PEAR's Numbers_Roman class such as:
The PEAR Number_Roman class translates regular numbers into their Roman equivalents. The class' toNumeral( ) method accepts an integer and outputs the corresponding Roman numeral. You can print a series of Roman numerals by combining the toNumeral( ) method with a loop, as shown here:
You can also reverse the process with the toNumber( ) method as in the following code snippet:
Note that toNumeral( ) does not support decimal or negative values. |
| | Give Your Opinion | Recommend |
|

