Current year in roman numerals using PHP
mins
Roman numeral convertor function
<?php
function numberToRomanRepresentation($number) {$map = 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);$returnValue = '';while ($number > 0) {foreach ($map as $roman => $int) {if($number >= $int) {$number -= $int;$returnValue .= $roman;break;}}}return $returnValue;}
?>
Print result
<?php
/*** use the current year as the number to convert ***/
$year = date('Y');
/*** echo the roman numeral for the year ***/
echo numberToRomanRepresentation($year);
?>