WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Function to convert Arabic numbers into Roman Numerals
Categories : Algorithms, PHP, Date Time Update Picture
Dave Weiner
Date : Feb 28th 2000
Grade : 4 of 5 (graded 2 times)
Viewed : 7421
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Dave Weiner
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

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
Dollar Serial Number Validator
Categories : PHP, Security, Algorithms
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
A very simple and efficient split bar the B-Z bar , for mysql and php ... Tired of obfuscated code try this one ...
Categories : PHP, Databases, MySQL, Algorithms
IPhider Obscure Any URL Anonymity connection lores obfuscation corporate survival.
Categories : PHP, Algorithms, Security, URLs
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character.
Categories : PHP, Algorithms, Security, Authentication, Encryption
Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers.
Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms
PHP Round Clock - Must have Gif support to use this.
Categories : PHP, Date Time, Graphics
A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed.
Categories : Date Time, PHP, Complete Programs, Calendar
A Timing Class
Categories : PHP, PHP Classes, Date Time
Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET
Categories : Algorithms, HTML and PHP, PHP, Variables
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL
Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms