Here's a little function I put together to convert an Arabic number between 0 and 9,999 to a
Roman Numeral. Initial testing went well, but it has not been fully tested yet.
<?
function to_roman($num) {
// Function to convert an arabic number ($num) to a roman numeral. $num must be between
0 and 9,999
// Copyright 2000 David L. Weiner <davew@webmast.com>. All Rights Reserved
if ($num < 0 || $num > 9999) { return -1; } // out of range
$r_ones = array(1=> "I", 2=>"II", 3=>"III", 4=>"IV", 5=>"V", 6=>"VI", 7=>"VII", 8=>"VIII",
9=>"IX");
$r_tens = array(1=> "X", 2=>"XX", 3=>"XXX", 4=>"XL", 5=>"L", 6=>"LX", 7=>"LXX",
8=>"LXXX", 9=>"XC");
$r_hund = array(1=> "C", 2=>"CC", 3=>"CCC", 4=>"CD", 5=>"D", 6=>"DC", 7=>"DCC",
8=>"DCCC", 9=>"CM");
$r_thou = array(1=> "M", 2=>"MM", 3=>"MMM", 4=>"MMMM", 5=>"MMMMM", 6=>"MMMMMM",
7=>"MMMMMMM", 8=>"MMMMMMMM", 9=>"MMMMMMMMM");
$ones = $num % 10;
$tens = ($num - $ones) % 100;
$hundreds = ($num - $tens - $ones) % 1000;
$thou = ($num - $hundreds - $tens - $ones) % 10000;
$tens = $tens / 10;
$hundreds = $hundreds / 100;
$thou = $thou / 1000;
if ($thou) { $rnum .= $r_thou[$thou]; }
if ($hundreds) { $rnum .= $r_hund[$hundreds]; }
if ($tens) { $rnum .= $r_tens[$tens]; }
if ($ones) { $rnum .= $r_ones[$ones]; }
return $rnum;
} // function to_roman($num)
?>
Find the day of the week for any given year/month/day. Categories : PHP , Date Time , Data Validation , Algorithms , Beginner Guides Prime number finder (Sieve of Erastothenes) Categories : PHP , Algorithms , Math. Website colour changer Categories : PHP , HTML and PHP , Date Time Kewl Date Example Categories : PHP , HTML and PHP , Date Time , CSS , Beginner Guides This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time. Categories : PHP , Calendar , Date Time , HTML and PHP A recursive function to traverse a multi-dimensional array where the
dimensions are not known Categories : Arrays , PHP , Algorithms List people whose birthdays fall on the current Day and Month
Categories : Databases , Date Time , MySQL , PHP How to validate an Israeli ID number. Categories : Ecommerce , PHP , Algorithms A class to put get and post variables in hidden form
elements. Works on scalars, normal arrays, associative
arrays. Categories : Algorithms , Variables , Arrays , PHP , PHP Classes Calendar, Kalender, date, time, day, month, year Categories : PHP , Date Time , Calendar Fast PI calculator. Can easily find the 1000th decimal place of pi in 5 seconds. Categories : PHP , BC math , Algorithms Kasskooye($path) tell you the complete size of a folder
Categories : PHP , Algorithms , Utilities , Filesystem This code consists of two parts, the first part is a .html file that uses a form to pass 3 date variables into day_of_week.php3 You input the mm/dd/yyyy of the day then
it prints what day of the week that day falls on. Categories : Date Time , PHP , Complete Programs Functions that will format a date in either long or short format from a string. Categories : Date Time , Strings , PHP Calendar using Date function Categories : HTML and PHP , PHP , Date Time , Calendar