3v4l.org

run code in 300+ PHP versions simultaneously
<?php function inclineWord($number, $word1, $word2, $word5) { if ($number % 100 >= 11 and $number % 100 <= 14) { return $word5; } elseif ($number % 10 == 1) { return $word1; } elseif ($number % 10 >= 2 and $number % 10 <= 4) { return $word2; } else return $word5; } function smallNumberToText($number, $isFemale) { $spelling = array( 0 => 'ноль', 10 => 'десять', 100 => 'сто', 1 => 'один', 11 => 'одиннадцать', 20 => 'двадцать', 200 => 'двести', 2 => 'два', 12 => 'двенадцать', 30 => 'тридцать', 300 => 'триста', 3 => 'три', 13 => 'тринадцать', 40 => 'сорок', 400 => 'четыреста', 4 => 'четыре', 14 => 'четырнадцать', 50 => 'пятьдесят', 500 => 'пятьсот', 5 => 'пять', 15 => 'пятнадцать', 60 => 'шестьдесят', 600 => 'шестьсот', 6 => 'шесть', 16 => 'шестнадцать', 70 => 'семьдесят', 700 => 'семьсот', 7 => 'семь', 17 => 'семнадцать', 80 => 'восемьдесят', 800 => 'восемьсот', 8 => 'восемь', 18 => 'восемнадцать', 90 => 'девяносто', 900 => 'девятьсот', 9 => 'девять', 19 => 'девятнадцать' ); $femaleSpelling = array( 1 => 'одна', 2 => 'две' ); $array = []; if ($number == 0) { return $spelling[$number]; } if ($number % 1000 >= 100 && $number % 1000 <= 999) { $array[] = $spelling[$number % 1000 - ($number % 1000 % 100)]; } if ($number % 100 >= 20 && $number % 100 <= 99) { $array[] = $spelling[$number % 100 - ($number % 100 % 10)]; } if ($number % 100 >= 10 && $number % 100 <= 19) { $array[] = $spelling[$number % 100]; } elseif ($isFemale == 0 && $number % 10 >= 1 && $number % 10 <= 9) { $array[] = $spelling[$number % 10]; } elseif ($isFemale == 1 && $number % 10 >= 1 && $number % 10 <= 2) { $array[] = $femaleSpelling[$number % 10]; } elseif ($isFemale == 1 && $number % 10 >= 3 && $number % 10 <= 9) { $array[] = $spelling[$number % 10]; } $result = implode(" ", $array); return $result; } function numberToText($number) { $array = []; if (floor($number / 1000000) > 0) { $array[] = smallNumberToText(floor($number / 1000000), 0) . inclineWord(floor($number / 1000000), " миллион", " миллиона", " миллионов"); } if (floor($number / 1000) > 0) { $array[] = smallNumberToText(floor($number / 1000), 1) . inclineWord(floor($number / 1000), " тысяча", " тысячи", " тысяч"); } if ($number > 0) { $array[] = smallNumberToText($number % 1000, 0) . inclineWord($number % 1000, " рубль", " рубля", " рублей"); } $result = implode(" ", $array); return $result; } $a = numberToText(120000); echo $a;

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.70.0180.00318.43
8.3.60.0070.01118.55
8.3.50.0120.00616.48
8.3.40.0000.01918.79
8.3.30.0140.00018.79
8.3.20.0040.00419.46
8.3.10.0060.00323.78
8.3.00.0040.00420.74
8.2.190.0110.00418.23
8.2.180.0040.01218.16
8.2.170.0040.01118.89
8.2.160.0000.01422.96
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0130.00326.16
8.2.120.0090.00021.13
8.2.110.0100.00022.38
8.2.100.0040.00717.91
8.2.90.0040.00417.91
8.2.80.0030.00618.16
8.2.70.0040.00417.93
8.2.60.0060.00318.34
8.2.50.0080.00018.10
8.2.40.0050.00319.60
8.2.30.0040.00420.59
8.2.20.0050.00318.14
8.2.10.0040.00418.39
8.2.00.0000.00819.45
8.1.280.0110.00425.92
8.1.270.0000.00823.96
8.1.260.0120.00326.35
8.1.250.0000.00828.09
8.1.240.0040.00820.50
8.1.230.0070.00420.95
8.1.220.0040.00420.96
8.1.210.0060.00318.77
8.1.200.0060.00317.25
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0000.00918.71
8.1.160.0040.00418.84
8.1.150.0000.00719.04
8.1.140.0030.00620.83
8.1.130.0040.00420.81
8.1.120.0070.00017.57
8.1.110.0060.00317.54
8.1.100.0040.00417.50
8.1.90.0070.00017.54
8.1.80.0000.00817.61
8.1.70.0100.00017.54
8.1.60.0000.00817.72
8.1.50.0030.00617.62
8.1.40.0040.00417.66
8.1.30.0050.00517.79
8.1.20.0030.00517.76
8.1.10.0020.00517.62
8.1.00.0030.00617.57
8.0.300.0050.00219.74
8.0.290.0060.00316.75
8.0.280.0000.00718.39
8.0.270.0080.00016.83
8.0.260.0040.00420.24
8.0.250.0030.00516.91
8.0.240.0030.00316.96
8.0.230.0000.00716.91
8.0.220.0000.00717.01
8.0.210.0000.00716.96
8.0.200.0000.00716.95
8.0.190.0040.00416.93
8.0.180.0070.00017.01
8.0.170.0090.00017.02
8.0.160.0000.00716.99
8.0.150.0000.00716.93
8.0.140.0070.00016.93
8.0.130.0000.00613.48
8.0.120.0080.00016.98
8.0.110.0080.00017.03
8.0.100.0050.00216.82
8.0.90.0030.00316.95
8.0.80.0090.00816.99
8.0.70.0000.00717.00
8.0.60.0000.00816.85
8.0.50.0080.00017.04
8.0.30.0120.00617.24
8.0.20.0060.01317.40
8.0.10.0050.00216.98
8.0.00.0020.01517.01
7.4.330.0050.00015.55
7.4.320.0070.00016.64
7.4.300.0040.00416.68
7.4.290.0030.00516.71
7.4.280.0050.00316.68
7.4.270.0000.00716.63
7.4.260.0000.01116.41
7.4.250.0050.00516.57
7.4.240.0070.00016.62
7.4.230.0050.00316.49
7.4.220.0000.00716.64
7.4.210.0080.00716.67
7.4.200.0000.00716.67
7.4.160.0080.00716.76
7.4.140.0100.00917.86
7.4.130.0060.01116.86
7.4.120.0120.00716.61
7.4.110.0000.01816.66
7.4.100.0070.01516.69
7.4.90.0100.00716.58
7.4.80.0100.00719.39
7.4.70.0100.01016.54
7.4.60.0150.00616.57
7.4.50.0040.01116.32
7.4.40.0190.00316.57
7.4.00.0040.01114.96
7.3.330.0000.00513.24
7.3.320.0000.00713.39
7.3.310.0030.00516.46
7.3.300.0030.00316.40
7.3.290.0000.00716.34
7.3.280.0060.01116.43
7.3.260.0130.01116.51
7.3.240.0120.00516.59
7.3.230.0130.00316.71
7.3.210.0100.00716.49
7.3.200.0060.00916.67
7.3.190.0100.00716.64
7.3.180.0090.01216.62
7.3.170.0130.00316.48
7.3.160.0100.00616.56
7.2.330.0070.01116.74
7.2.320.0070.01116.90
7.2.310.0110.00616.56
7.2.300.0100.00616.92
7.2.290.0070.01016.81
7.2.90.1170.00814.66
7.2.80.0980.00714.89
7.2.70.0120.01214.66
7.2.60.0090.01214.87
7.2.50.0080.00914.91
7.2.40.0100.01314.62
7.2.30.0160.00515.05
7.2.20.1260.00314.54
7.2.10.0090.01215.14
7.2.00.0560.00715.15
7.1.210.0080.00313.88
7.1.200.0100.00614.02
7.1.190.0440.00614.16
7.1.180.0240.00913.78
7.1.170.1530.00013.78
7.1.160.0290.01013.42
7.1.150.0090.01213.96
7.1.140.0150.00413.94
7.1.130.0100.01413.90
7.1.120.0080.01113.87
7.1.110.0120.00613.93
7.1.100.1560.00614.07
7.1.90.0120.00613.79
7.1.80.0280.00813.83
7.1.70.0050.00913.96
7.1.60.2190.01431.60
7.1.50.2200.01331.73
7.1.40.2370.01332.00
7.1.30.0280.00431.57
7.1.20.1530.00331.82
7.1.10.0090.00914.00
7.1.00.0280.01313.76

preferences:
17.74 ms | 401 KiB | 5 Q