3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* |----------------------------------------------------------------------------------------------------------------------- | Negative roman numbers?! :D - No apparent concept of negatives here. | So we could just stick to normal negative numbers. |----------------------------------------------------------------------------------------------------------------------- */ # normal negative numbers $roman = '-x: =#,##0=;'; # "Just for fun/Unofficial" negative roman numerals #$roman = '-x: ->>;'; /* |----------------------------------------------------------------------------------------------------------------------- | No concept of zero here. | The number zero does not have its own Roman numeral, but the word nulla (the Latin word meaning "none") | was used by medieval scholars in lieu of 0. Dionysius Exiguus was known to use nulla alongside Roman numerals | in 525. | | 0: nulla | 0: N | The N could also be used. https://en.wikipedia.org/wiki/Roman_numerals#Zero |----------------------------------------------------------------------------------------------------------------------- */ # $roman = '0: N;'; $roman .= '0: nulla;'; /* |----------------------------------------------------------------------------------------------------------------------- | The larger numbers |----------------------------------------------------------------------------------------------------------------------- */ $roman .= <<<RULE_BASED_FORMAT I; II; III; IV; V; VI; VII; VIII; IX; 10: X>>; 20: XX>>; 30: XXX>>; 40: XL>>; 50: L>>; 60: LX>>; 70: LXX>>; 80: LXXX>>; 90: XC>>; 100: C>>; 400: CD>>; 500: D>>; 600: DC>>; 900: CM>>; 1000: M>>; 2000: MM>>; 3000: MMM>>; 4000: MMMM>>; RULE_BASED_FORMAT; /* |----------------------------------------------------------------------------------------------------------------------- | The larger numbers |----------------------------------------------------------------------------------------------------------------------- */ $roman .= <<<RULE_BASED_FORMAT 5000: V\u{0305}>>; 6000: V\u{0305}M>>; 7000: V\u{0305}MM>>; 8000: V\u{0305}MMM>>; 9000: V\u{0305}MMMM>>; 10000: X\u{0305}>>; 20000: X\u{0305}X\u{0305}>>; 30000: X\u{0305}X\u{0305}X\u{0305}>>; 40000: X\u{0305}L\u{0305}>>; 50000: L\u{0305}>>; 60000: L\u{0305}X\u{0305}>>; 70000: L\u{0305}X\u{0305}X\u{0305}>>; 80000: L\u{0305}X\u{0305}X\u{0305}X\u{0305}>>; 90000: X\u{0305}C\u{0305}>>; 100000: C\u{0305}>>; 200000: C\u{0305}C\u{0305}>>; 300000: C\u{0305}C\u{0305}C\u{0305}>>; 400000: C\u{0305}D\u{0305}>>; 500000: D\u{0305}>>; 600000: D\u{0305}C\u{0305}>>; 700000: D\u{0305}C\u{0305}C\u{0305}>>; 800000: D\u{0305}C\u{0305}C\u{0305}C\u{0305}>>; 900000: C\u{0305}M\u{0305}>>; 1000000: M\u{0305}>>; 2000000: M\u{0305}M\u{0305}>>; 3000000: M\u{0305}M\u{0305}M\u{0305}>>; 4000000: I\u{033F}V\u{033F}>>; 5000000: V\u{033F}>>; 6000000: V\u{033F}I\u{033F}>>; 7000000: V\u{033F}I\u{033F}I\u{033F}>>; 8000000: V\u{033F}I\u{033F}I\u{033F}I\u{033F}>>; 9000000: I\u{033F}X\u{033F}>>; 10000000: X\u{033F}>>; 20000000: X\u{033F}X\u{033F}>>; 30000000: X\u{033F}X\u{033F}X\u{033F}>>; 40000000: X\u{033F}L\u{033F}>>; 50000000: L\u{033F}>>; 60000000: L\u{033F}X\u{033F}>>; 70000000: L\u{033F}X\u{033F}X\u{033F}>>; 80000000: L\u{033F}X\u{033F}X\u{033F}X\u{033F}>>; 90000000: X\u{033F}C\u{033F}>>; 100000000: C\u{033F}>>; 200000000: C\u{033F}C\u{033F}>>; 300000000: C\u{033F}C\u{033F}C\u{033F}>>; 400000000: C\u{033F}D\u{033F}>>; 500000000: D\u{033F}>>; 600000000: D\u{033F}C\u{033F}>>; 700000000: D\u{033F}C\u{033F}C\u{033F}>>; 800000000: D\u{033F}C\u{033F}C\u{033F}C\u{033F}>>; 900000000: C\u{033F}M\u{033F}>>; 1000000000: M\u{033F}>>; 2000000000: M\u{033F}M\u{033F}>>; 3000000000: M\u{033F}M\u{033F}M\u{033F}>>; 4000000000: M\u{033F};M\u{033F};M\u{033F};M\u{033F}>>; RULE_BASED_FORMAT; /* |----------------------------------------------------------------------------------------------------------------------- | Then go back to normal numbers |----------------------------------------------------------------------------------------------------------------------- */ $roman .= <<<RULE_BASED_FORMAT 5000000000: =#,##0=; RULE_BASED_FORMAT; header('Content-Type: text/html; charset=utf-8'); $fmt = new NumberFormatter('en', NumberFormatter::PATTERN_RULEBASED, $roman); $year = $fmt->format(2014); $game = $fmt->format(22); echo "Year $year, $game Olympic Winter Games"; /* |----------------------------------------------------------------------------------------------------------------------- | Sources: | https://en.wikipedia.org/wiki/Roman_numerals | http://www.tuomas.salste.net/doc/roman/numeri-romani-learn.html | https://en.wikipedia.org/wiki/1,000,000,000 | https://forbrains.co.uk/free_online_tools/convert_to_roman_numerals | https://en.wikipedia.org/wiki/Numerals_in_Unicode#Roman_numerals_in_Unicode | http://userguide.icu-project.org/formatparse/numbers/rbnf-examples | | Warning, there are more than one ways to write certain numbers, and some | can even mean two different numbers. | | Example: "V̅I̅I̅I̅" can mean 80,000 or 800,000 | See https://en.wikipedia.org/wiki/Roman_numerals#Vinculum |----------------------------------------------------------------------------------------------------------------------- */
Output for git.master, git.master_jit, rfc.property-hooks
Year MMXIV, XXII Olympic Winter Games

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:
26.22 ms | 401 KiB | 8 Q