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 ($lookup as $roman => $value) { $matches = intval($n / $value); $result .= str_repeat($roman, $matches); $n = $n % $value; } return ((bool)$uppercase) ? strtoupper($result) : $result; } }