The NumberFormatter class can be used to convert integer numbers to Roman numerals without a custom function using an array of symbols and associated values:
<?php
function intToRomanNumeral(int $num) {
static $nf = new NumberFormatter('@numbers=roman', NumberFormatter::DECIMAL);
return $nf->format($num);
}
echo intToRomanNumeral(2); echo intToRomanNumeral(5); echo intToRomanNumeral(10); echo intToRomanNumeral(50); echo intToRomanNumeral(57); echo intToRomanNumeral(58); echo intToRomanNumeral(100); echo intToRomanNumeral(150); echo intToRomanNumeral(1000); echo intToRomanNumeral(10000); ?>