<?php function getRomanNumerals($decimalInteger) { $n = intval($decimalInteger); $res = ''; $roman_numerals = array( 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1); foreach ($roman_numerals as $roman => $numeral) { $matches = intval($n / $numeral); $res .= str_repeat($roman, $matches); $n = $n % $numeral; } return $res; } echo getRomanNumerals(32); ////Example Use - returns XXXII ?>
Any improvements? Drop us a comment. Thanks!
Tahnks!!!
ReplyDeleteit would be nice if explained in comments
ReplyDeletekuşadası
ReplyDeletemilas
çeşme
bağcılar
urfa
A2KJ4B