get romawi number php

Solutions on MaxInterview for get romawi number php by the best coders in the world

showing results for - "get romawi number php"
Francesca
01 Jan 2018
1/**
2 * @param int $number
3 * @return string
4 */
5function numberToRomanRepresentation($number) {
6    $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);
7    $returnValue = '';
8    while ($number > 0) {
9        foreach ($map as $roman => $int) {
10            if($number >= $int) {
11                $number -= $int;
12                $returnValue .= $roman;
13                break;
14            }
15        }
16    }
17    return $returnValue;
18}
19
similar questions
queries leading to this page
get romawi number php