PHP Classes

Numeral: Convert numbers between Roman and Hindu formats

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 122 All time: 9,473 This week: 206Up
Version License PHP version Categories
numeral 1.0GNU General Publi...5.2PHP 5, Text processing, Math


This class can be used to convert numbers between Roman or Hindu formats.

It takes an integer number and converts it to Roman format.

The class can also do the opposite, i.e. convert Roman numeral and convert it back to an integer.

Picture of Gordon Pettey
Name: Gordon Pettey <contact>
Classes: 1 package by
Country: United States United States
Age: 36
All time rank: 4353550 in United States United States
Week rank: 307 Up35 in United States United States Up




$num = new numeral(); // Numeral object.
$value = array(); // Array of values to test with.
$value[] = 2008;
$value[] = "1997";
$value[] = "MCCCXXXVII";
$value[] = 5000;
$value[] = "MCMLXXXVII";
$value[] = "1987";
$value[] = 60000;
$value[] = 500000;
$value[] = 16777216;
$value[] = "_M_M_M_M_M_M_M_M_M_M_M_M_M_M_M_M_D_C_C_L_X_X_VMMCCXVI";
// Underscore used in place of "overbar"

foreach($value as $var) { // Loop through test values using numeral
$num->setValue($var); // object with preset value.
echo $num->getValue()." - ";
$num->getType()." - ";
$num->getHindu()." - ";
$num->getRoman()." - ";
$num->convert()."<br />";
"<br />";

"<br /><br /><br />";

$num2 = new numeral(); // Create a second numeral object.
foreach($value as $var) { // This time, loop through while setting the
echo $num2->getValue($var)." - "; // value as a parameter of each method.
echo $num2->getType($var)." - ";
$num2->getHindu($var)." - ";
$num2->getRoman($var)." - ";
$num2->convert($var)."<br />";
"<br />";


  Files folder image Files  
File Role Description
Plain text file class.numeral.php Class Main class file
Accessible without login Plain text file example.php Example Example script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,473
This week:206Up