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 |----------------------------------------------------------------------------------------------------------------------- */

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0060.01620.68
8.3.50.0140.00720.42
8.3.40.0030.01320.40
8.3.30.0120.00320.47
8.3.20.0000.00821.84
8.3.10.0030.00623.59
8.3.00.0030.00623.52
8.2.180.0340.00618.63
8.2.170.0080.00822.96
8.2.160.0090.00623.79
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0050.00323.31
8.2.120.0030.00626.35
8.2.110.0060.00323.07
8.2.100.0040.00820.16
8.2.90.0000.01019.88
8.2.80.0000.00820.36
8.2.70.0030.00619.75
8.2.60.0090.00519.74
8.2.50.0000.00819.75
8.2.40.0090.00420.90
8.2.30.0040.00420.91
8.2.20.0080.00020.21
8.2.10.0030.00520.23
8.2.00.0070.00320.22
8.1.280.0120.00325.92
8.1.270.0000.00823.40
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0040.00723.22
8.1.230.0090.00323.11
8.1.220.0080.00020.32
8.1.210.0060.00319.36
8.1.200.0060.00319.35
8.1.190.0090.00419.22
8.1.180.0080.00019.25
8.1.170.0050.00520.71
8.1.160.0000.00920.47
8.1.150.0040.00421.65
8.1.140.0050.00319.81
8.1.130.0040.00420.56
8.1.120.0050.00319.54
8.1.110.0000.00819.70
8.1.100.0040.00419.71
8.1.90.0000.00819.63
8.1.80.0040.00419.70
8.1.70.0030.00519.69
8.1.60.0030.00519.74
8.1.50.0040.00419.42
8.1.40.0030.00519.73
8.1.30.0040.00419.68
8.1.20.0050.00319.81
8.1.10.0050.00319.84
8.1.00.0000.01019.87
8.0.300.0090.00418.77
8.0.290.0050.00518.63
8.0.280.0000.00920.06
8.0.270.0040.00419.22
8.0.260.0040.00420.57
8.0.250.0000.00719.11
8.0.240.0000.00918.94
8.0.230.0040.00418.88
8.0.220.0050.00318.96
8.0.210.0000.00818.96
8.0.200.0000.00718.87
8.0.190.0040.00419.07
8.0.180.0060.00319.02
8.0.170.0040.00419.03
8.0.160.0040.00418.86
8.0.150.0000.00818.82
8.0.140.0000.00919.09
8.0.130.0030.00313.43
8.0.120.0030.00519.23
8.0.110.0000.00819.13
8.0.100.0000.00819.11
8.0.90.0000.00819.26
8.0.80.0060.00918.98
8.0.70.0080.00019.27
8.0.60.0000.00819.14
8.0.50.0040.00419.30
8.0.30.0110.01019.36
8.0.20.0120.01019.29
8.0.10.0030.00619.35
8.0.00.0090.00918.95
7.4.330.0000.00415.55
7.4.320.0060.00018.83
7.4.300.0040.00718.68
7.4.290.0140.00418.82
7.4.280.0000.00818.63
7.4.270.0070.00018.80
7.4.260.0110.00718.58
7.4.250.0040.00418.84
7.4.240.0000.00718.85
7.4.230.0000.00718.80
7.4.220.0070.01418.55
7.4.210.0120.00918.63
7.4.200.0050.00318.61
7.4.160.0100.01118.79
7.4.150.0120.00618.55
7.4.140.0100.00918.57
7.4.130.0090.01618.72
7.4.120.0090.01118.75
7.4.110.0110.00818.43
7.4.100.0100.01318.74
7.4.90.0060.01218.50
7.4.80.0120.01119.39
7.4.70.0030.01718.56
7.4.60.0070.01018.64
7.4.50.0120.00218.71
7.4.40.0090.00918.39
7.4.30.0080.00818.74
7.4.00.0030.01317.53
7.3.330.0030.00313.13
7.3.320.0000.00513.15
7.3.310.0040.00418.45
7.3.300.0000.00818.41
7.3.290.0130.00818.41
7.3.280.0080.00918.43
7.3.270.0070.01018.34
7.3.260.0110.00918.51
7.3.250.0090.01018.63
7.3.240.0090.00918.50
7.3.230.0070.01118.62
7.3.210.0110.00718.67
7.3.200.0150.00318.33
7.3.190.0060.01118.64
7.3.180.0140.00418.79
7.3.170.0110.01318.50
7.3.160.0040.01418.50
7.2.330.0070.01118.79
7.2.320.0060.01218.91
7.2.310.0140.00418.56
7.2.300.0070.01218.37
7.2.290.0030.01518.48
7.2.60.0070.00719.00
7.1.200.0040.01118.31
7.1.100.0110.01120.51
7.1.90.0150.00620.35
7.1.80.0150.00620.45
7.1.70.0150.00619.25
7.1.60.0250.01937.25
7.1.50.0320.01337.18
7.1.40.0290.01536.96
7.1.30.0230.02637.17
7.1.20.0330.01536.78
7.1.10.0000.02318.79
7.1.00.0110.01118.92
7.0.240.0090.01620.00
7.0.230.0120.00920.01
7.0.220.0130.00920.11
7.0.210.0070.01318.91
7.0.200.0170.00319.07
7.0.190.0130.00918.98
7.0.180.0060.01518.39
7.0.170.0110.01118.51
7.0.160.0110.01418.63
7.0.150.0090.01218.73
7.0.140.0030.01418.72
7.0.130.0160.00518.89
7.0.120.0160.00618.76
7.0.110.0060.01518.50
7.0.100.0110.01118.39
7.0.90.0060.01618.30
7.0.80.0060.01618.37
7.0.70.0090.01418.41
7.0.60.0060.01618.43
7.0.50.0030.01618.55
7.0.40.0090.00918.29
7.0.30.0030.01718.42
7.0.20.0070.00918.52
7.0.10.0070.01318.38
7.0.00.0150.00718.51

preferences:
32.49 ms | 400 KiB | 5 Q