3v4l.org

run code in 300+ PHP versions simultaneously
<?php function numberToRoman(int $integer): string { static $conversions = [ 1000 => 'M', 900 => 'CM', 500 => 'D', 400 => 'CD', 100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL', 10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I' ]; $romanString = ''; foreach ($conversions as $int => $roman) { while ($integer >= $int) { $romanString .= $roman; $integer -= $int; if (!$integer) { break 2; } } } return $romanString; } echo numberToRoman(3333); echo "\n---\n"; echo numberToRoman(5000);
Output for git.master, git.master_jit, rfc.property-hooks
MMMCCCXXXIII --- MMMMM

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
87.27 ms | 405 KiB | 5 Q