3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Staring straight up into the sky ... oh my my error_reporting(-1); mb_internal_encoding('utf-8'); /* Возвращает соответствующую числу форму слова: 1 рубль, 2 рубля, 5 рублей */ function inclineWord($number, $word1, $word2, $word3) { if ($number % 100 >= 10 && $number % 100 <= 19) { return $word3; } elseif ($number % 10 >= 2 && $number % 10 <= 4) { return $word2; } elseif ($number % 10 == 1) { return $word1; } else { return $word3; } } /* Преобразует числа от 0 до 999 в текст. Параметр $isFemale равен нулю, если мы считаем число для мужского рода (один рубль), и 1 — для женского (одна тысяча) */ 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 => 'две' ); $text = ""; if ($number > 100) { $reviewNumber = floor($number / 100) * 100; $text = $text." ".$spelling[$reviewNumber]; $number %= 100; } if ($number >= 10 && $number <= 19) { return $text." ".$spelling[$number]; } elseif ($number > 10) { $reviewNumber = floor($number / 10) * 10; $text = $text." ".$spelling[$reviewNumber]; $number %= 10; } if ($isFemale == 1 && $number == 1) { $text = $text." ".$femaleSpelling[1]; } elseif ($isFemale == 1 && $number == 2) { $text = $text." ".$femaleSpelling[2]; } elseif ($number > 0) { $text = $text." ".$spelling[$number]; } return $text; } function numberToText($number) { $baseNumber = $number; $text = ""; if ($number == 0) { return "ноль (0) рублей"; exit; } if (floor($number / 1000000) >= 1) { $numberIterationToSplit = 3; } elseif (floor($number / 1000) >= 1) { $numberIterationToSplit = 2; } else { $numberIterationToSplit = 1; } for ($i = 0; $i < $numberIterationToSplit; $i++) { if ($number % 1000 == 0 && $i != 0) { $number = floor($number / 1000); continue; } if ($i == 1) { $isFemale = 1; } else { $isFemale = 0; } if ($i == 0){ $wordForNumber = "(".$baseNumber.") ".inclineWord($number, "рубль", "рубля", "рублей"); } elseif ($i == 1) { $wordForNumber = inclineWord($number, "тысяча", "тысячи", "тысяч"); } else { $wordForNumber = inclineWord($number, "миллион", "миллиона", "миллионов"); } $text = smallNumberToText($number % 1000, $isFemale)." ".$wordForNumber.$text; $number = floor($number / 1000); } return $text; } /* Вызовем функцию несколько раз */ $amount1 = mt_rand(1,99999999); $text1 = numberToText($amount1); echo "На вашем счету{$text1}\n"; $amount2 = mt_rand(1,99999999); $text2 = numberToText($amount2); echo "На вашем счету{$text2}\n"; $amount3 = mt_rand(1,99999999); $text3 = numberToText($amount3); echo "На вашем счету{$text3}\n"; $amount4 = mt_rand(1,99999999); $text4 = numberToText($amount4); echo "На вашем счету{$text4}\n";

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.5.90.0070.00818.70
8.5.80.0110.00618.66
8.5.70.0100.00818.50
8.5.60.0090.00518.39
8.5.50.0030.00518.41
8.5.40.0060.00318.27
8.5.30.0130.00518.20
8.5.20.0130.00818.58
8.5.10.0240.00816.45
8.5.00.0130.00816.78
8.4.240.0200.00819.72
8.4.230.0130.01319.76
8.4.220.0180.01019.65
8.4.210.0150.01119.74
8.4.200.0270.00619.58
8.4.190.0090.01219.54
8.4.180.0100.00319.68
8.4.170.0130.01319.67
8.4.160.0160.01119.85
8.4.150.0180.00719.79
8.4.140.0140.01117.72
8.4.130.0210.00417.81
8.4.120.0170.00718.01
8.4.110.0140.01117.91
8.4.100.0190.00817.93
8.4.90.0170.00719.75
8.4.80.0150.00919.50
8.4.70.0170.00719.72
8.4.60.0170.01017.90
8.4.50.0190.00619.61
8.4.40.0140.01119.52
8.4.30.0170.00619.30
8.4.20.0180.00919.52
8.4.10.0160.00819.43
8.3.330.0150.00920.15
8.3.320.0170.00820.30
8.3.310.0170.00820.27
8.3.300.0180.00720.13
8.3.290.0160.00820.19
8.3.280.0160.00820.12
8.3.270.0160.00718.64
8.3.260.0160.00718.45
8.3.250.0170.00718.52
8.3.240.0150.00818.61
8.3.230.0170.00518.46
8.3.220.0160.00718.50
8.3.210.0130.01018.60
8.3.200.0150.00718.52
8.3.190.0120.01018.61
8.3.180.0150.00418.58
8.3.170.0140.00918.45
8.3.160.0150.00818.49
8.3.150.0160.00718.48
8.3.140.0170.00618.61
8.3.130.0140.00818.70
8.3.120.0160.00618.61
8.3.110.0110.00718.62
8.3.100.0180.00518.47
8.3.90.0150.00818.62
8.3.80.0130.01018.59
8.3.70.0180.00618.54
8.3.60.0130.00918.61
8.3.50.0130.00918.49
8.3.40.0200.00919.82
8.3.30.0140.00619.90
8.3.20.0110.00619.84
8.3.10.0130.00418.05
8.3.00.0130.00918.06
8.2.330.0160.00718.10
8.2.320.0160.00817.94
8.2.310.0150.00918.13
8.2.300.0250.01117.98
8.2.290.0280.00716.65
8.2.280.0280.00716.61
8.2.270.0290.00816.59
8.2.260.0280.00916.52
8.2.250.0280.00916.44
8.2.240.0260.01116.68
8.2.230.0320.00716.45
8.2.220.0280.00916.46
8.2.210.0260.01016.40
8.2.200.0310.00716.53
8.2.190.0280.00916.58
8.2.180.0290.00816.61
8.2.170.0280.01018.17
8.2.160.0280.00618.26
8.2.150.0240.01018.01
8.2.140.0260.00918.14
8.2.130.0300.00818.14
8.2.120.0320.00418.02
8.2.110.0290.00618.07
8.2.100.0280.00917.98
8.2.90.0260.01117.86
8.2.80.0320.00717.85
8.2.70.0300.00717.77
8.2.60.0170.00718.02
8.2.50.0290.00717.91
8.2.40.0300.00717.91
8.2.30.0260.01117.92
8.2.20.0260.01017.95
8.2.10.0260.00817.90
8.2.00.0240.00717.91
8.1.340.0290.01017.54
8.1.330.0240.00816.34
8.1.320.0260.00316.23
8.1.310.0180.00816.35
8.1.300.0300.00816.31
8.1.290.0300.00816.15
8.1.280.0300.00715.96
8.1.270.0330.01017.62
8.1.260.0280.00817.96
8.1.250.0180.00917.63
8.1.240.0170.00917.92
8.1.230.0150.01117.84
8.1.220.0160.00917.93
8.1.210.0190.00817.86
8.1.200.0130.01217.54
8.1.190.0240.01217.42
8.1.180.0180.00917.61
8.1.170.0150.01117.67
8.1.160.0150.00817.81
8.1.150.0120.00917.67
8.1.140.0130.00917.70
8.1.130.0180.00417.81
8.1.120.0260.00817.88
8.1.110.0190.00617.83
8.1.100.0160.01017.83
8.1.90.0130.01217.74
8.1.80.0180.00817.83
8.1.70.0200.00817.59
8.1.60.0200.00617.82
8.1.50.0220.00917.82
8.1.40.0170.00817.82
8.1.30.0120.01217.84
8.1.20.0180.00817.89
8.1.10.0180.00817.83
8.1.00.0150.01117.83
8.0.300.0220.00417.10
8.0.290.0160.00916.86
8.0.280.0180.00717.10
8.0.270.0110.01317.20
8.0.260.0180.00517.09
8.0.250.0170.00517.22
8.0.240.0130.00818.84
8.0.230.0090.01118.82
8.0.220.0100.00918.96
8.0.210.0240.01016.92
8.0.200.0270.00817.04
8.0.190.0300.00517.23
8.0.180.0250.00317.25
8.0.170.0320.00417.01
8.0.160.0310.00417.16
8.0.150.0290.00517.01
8.0.140.0170.00917.09
8.0.130.0270.01016.75
8.0.120.0140.00718.87
8.0.110.0130.01018.76
8.0.100.0130.00818.59
8.0.90.0120.00818.75
8.0.80.0120.00718.76
8.0.70.0160.00418.75
8.0.60.0090.01118.62
8.0.50.0170.00318.88
8.0.30.0110.01018.88
8.0.20.0110.00819.01
8.0.10.0130.00819.09
8.0.00.0100.01019.18
7.4.330.0150.00318.52
7.4.320.0100.01018.43
7.4.300.0190.00317.00
7.4.290.0080.01018.64
7.4.280.0110.00818.60
7.4.270.0090.01118.64
7.4.260.0130.00618.64
7.4.250.0130.00618.57
7.4.240.0100.00818.57
7.4.230.0110.00718.57
7.4.220.0200.00716.84
7.4.210.0110.00918.57
7.4.200.0120.00818.57
7.4.190.0090.01018.55
7.4.180.0100.00918.62
7.4.160.0080.00318.62
7.4.150.0170.00518.50
7.4.140.0110.00918.51
7.4.130.0120.00818.29
7.4.120.0130.00718.41
7.4.110.0210.00716.77
7.4.100.0090.01118.54
7.4.90.0060.00318.52
7.4.80.0070.00218.42
7.4.70.0100.00418.46
7.4.60.0080.00918.52
7.4.50.0110.00718.50
7.4.40.0090.00918.37
7.4.30.0080.01018.49
7.4.20.0100.00818.43
7.4.10.0180.00816.77
7.4.00.0150.00418.48
7.3.330.0110.00818.27
7.3.320.0070.01118.42
7.3.310.0110.00718.45
7.3.300.0100.00718.42
7.3.290.0120.00918.30
7.3.280.0110.00718.42
7.3.270.0140.00418.45
7.3.260.0120.00718.37
7.3.250.0230.00516.75
7.3.240.0120.00718.45
7.3.230.0040.00518.41
7.3.220.0150.00418.34
7.3.210.0050.00318.38
7.3.200.0110.00318.48
7.3.190.0100.00518.21
7.3.180.0090.00918.35
7.3.170.0120.00618.35
7.3.160.0110.00518.35
7.3.150.0170.01016.55
7.3.140.0120.00718.38
7.3.130.0120.00618.35
7.3.120.0100.00818.38
7.3.110.0120.00718.33
7.3.100.0110.00718.36
7.3.90.0100.00818.75
7.3.80.0130.00518.25
7.3.70.0120.00718.46
7.3.60.0100.00818.66
7.3.50.0180.00418.53
7.3.40.0180.00218.56
7.3.30.0150.00716.75
7.3.20.0300.00616.69
7.3.10.0160.00616.64
7.3.00.0310.00716.03
7.2.340.0090.01018.34
7.2.330.0260.00516.74
7.2.320.0230.01016.60
7.2.310.0240.00816.53
7.2.300.0240.00816.39
7.2.290.0230.01016.61
7.2.280.0230.00916.53
7.2.270.0250.00816.69
7.2.260.0260.00816.59
7.2.250.0270.00716.68
7.2.240.0200.01016.63
7.2.230.0250.00916.67
7.2.220.0250.00916.72
7.2.210.0230.01116.60
7.2.200.0270.00816.91
7.2.190.0320.00416.95
7.2.180.0130.00316.81
7.2.170.0230.00616.49
7.2.160.0140.00415.95
7.2.150.0410.00516.91
7.2.140.0320.00716.70
7.2.130.0380.00616.40
7.2.120.0290.00516.43
7.2.110.0290.01016.33
7.2.100.0310.00916.43
7.2.90.0440.00516.36
7.2.80.0340.00816.46
7.2.70.0290.00616.43
7.2.60.0250.00816.41
7.2.50.0350.00616.42
7.2.40.0330.00616.35
7.2.30.0320.00716.52
7.2.20.0280.01016.44
7.2.10.0330.00616.43
7.2.00.0300.00716.43
7.1.330.0150.00817.55
7.1.320.0160.00717.36
7.1.310.0150.00717.65
7.1.300.0130.00817.45
7.1.290.0090.00817.55
7.1.280.0110.00617.61
7.1.270.0290.00315.74
7.1.260.0290.00515.76
7.1.250.0290.00715.19
7.1.240.0350.00815.71
7.1.230.0350.00615.77
7.1.220.0390.00215.82
7.1.210.0410.00615.66
7.1.200.0350.00715.79
7.1.190.0400.01115.88
7.1.180.0300.00615.85
7.1.170.0360.00715.74
7.1.160.0380.00615.62
7.1.150.0370.00915.90
7.1.140.0690.00715.82
7.1.130.0450.00315.82
7.1.120.0390.00815.79
7.1.110.0360.00815.78
7.1.100.0270.00915.88
7.1.90.0380.01115.87
7.1.80.0330.00815.94
7.1.70.0310.00915.77
7.1.60.0390.00715.79
7.1.50.0390.00115.95
7.1.40.0390.00715.82
7.1.30.0220.00615.65
7.1.20.0300.00815.82
7.1.10.0330.00515.78
7.1.00.0320.00815.83
7.0.330.0360.00515.33
7.0.320.0420.00515.50
7.0.310.0370.00815.51
7.0.300.0370.00615.44
7.0.290.0400.00615.40
7.0.280.0490.00515.46
7.0.270.0530.01115.36
7.0.260.0280.00715.40
7.0.250.0360.00715.53
7.0.240.0350.00715.49
7.0.230.0360.00615.61
7.0.220.0360.00515.52
7.0.210.0270.00715.61
7.0.200.0200.01115.61
7.0.190.0340.00815.51
7.0.180.0350.00715.30
7.0.170.0380.00815.66
7.0.160.0310.00815.52
7.0.150.0290.00915.52
7.0.140.0320.00815.46
7.0.130.0720.01315.45
7.0.120.0340.00415.61
7.0.110.0480.00715.42
7.0.100.0240.01415.51
7.0.90.0320.00515.55
7.0.80.0370.00615.45
7.0.70.0370.00815.42
7.0.60.0370.00415.56
7.0.50.0340.00915.34
7.0.40.0330.01015.52
7.0.30.0350.00715.44
7.0.20.0300.00615.24
7.0.10.0290.01115.51
7.0.00.0400.00815.51
5.6.400.0130.01415.43
5.6.390.0100.01115.33
5.6.380.0130.01115.17
5.6.370.0090.00915.50
5.6.360.0100.01015.42
5.6.350.0140.00915.38
5.6.340.0070.01015.55
5.6.330.0130.01015.16
5.6.320.0140.00715.35
5.6.310.0160.01015.52
5.6.300.0210.00415.25
5.6.290.0130.01215.27
5.6.280.0150.00915.46
5.6.270.0110.00715.35
5.6.260.0130.01015.46
5.6.250.0130.00815.47
5.6.240.0130.00915.51
5.6.230.0170.01115.50
5.6.220.0140.01015.40
5.6.210.0190.00715.63
5.6.200.0130.01115.57
5.6.190.0210.01115.26
5.6.180.0200.00815.51
5.6.170.0160.00815.56
5.6.160.0230.00715.59
5.6.150.0190.00915.34
5.6.140.0220.00815.33
5.6.130.0190.00515.48
5.6.120.0230.00515.61
5.6.110.0230.00815.34
5.6.100.0190.00615.28
5.6.90.0170.00915.35
5.6.80.0110.01115.21
5.6.70.0150.00915.56
5.6.60.0170.00715.41
5.6.50.0170.00615.32
5.6.40.0170.00715.28
5.6.30.0180.00515.25
5.6.20.0160.01115.30
5.6.10.0200.00615.04
5.6.00.0150.00515.21
5.5.380.0130.00915.41
5.5.370.0170.00915.43
5.5.360.0160.00915.13
5.5.350.0190.00915.26
5.5.340.0180.01315.23
5.5.330.0150.00915.28
5.5.320.0180.01015.15
5.5.310.0240.00515.24
5.5.300.0190.01015.37
5.5.290.0180.00815.17
5.5.280.0180.00715.27
5.5.270.0230.00915.36
5.5.260.0200.00815.42
5.5.250.0210.00415.25
5.5.240.0190.00715.32
5.5.230.0170.00615.38
5.5.220.0140.00815.32
5.5.210.0260.00315.22
5.5.200.0200.00415.34
5.5.190.0150.00715.32
5.5.180.0190.00415.30
5.5.170.0180.00615.28
5.5.160.0130.01115.37
5.5.150.0210.00515.20
5.5.140.0180.00615.33
5.5.130.0160.00915.38
5.5.120.0180.00615.25
5.5.110.0170.01015.26
5.5.100.0190.00515.42
5.5.90.0180.00815.36
5.5.80.0150.00615.50
5.5.70.0200.01115.54
5.5.60.0180.00615.46
5.5.50.0200.00415.38
5.5.40.0180.00915.21
5.5.30.0170.00615.30
5.5.20.0170.01015.35
5.5.10.0200.00515.30
5.5.00.0160.00815.12
5.4.450.0130.00613.40
5.4.440.0130.00713.37
5.4.430.0130.00513.34
5.4.420.0160.00813.39
5.4.410.0140.00613.33
5.4.400.0130.00813.26
5.4.390.0180.00313.23
5.4.380.0180.00313.31
5.4.370.0130.00213.32
5.4.360.0080.00513.31
5.4.350.0150.00413.17
5.4.340.0120.00613.19
5.4.330.0130.00913.27
5.4.320.0130.00613.26
5.4.310.0110.00613.29
5.4.300.0110.00613.20
5.4.290.0130.00213.30
5.4.280.0080.00513.34
5.4.270.0150.00413.31
5.4.260.0140.00713.38
5.4.250.0120.00513.35
5.4.240.0160.00313.23
5.4.230.0130.00613.33
5.4.220.0160.00413.20
5.4.210.0170.00213.23
5.4.200.0150.00313.32
5.4.190.0120.00613.25
5.4.180.0170.00213.27
5.4.170.0140.00513.21
5.4.160.0110.01013.34
5.4.150.0120.00613.28
5.4.140.0140.00413.28
5.4.130.0150.00613.29
5.4.120.0140.00313.24
5.4.110.0120.00613.15
5.4.100.0170.00313.34
5.4.90.0100.00813.18
5.4.80.0140.00513.28
5.4.70.0100.00813.25
5.4.60.0150.00213.33
5.4.50.0170.00313.19
5.4.40.0130.00913.31
5.4.30.0160.00413.32
5.4.20.0140.00613.23
5.4.10.0100.00713.30
5.4.00.0090.00913.26
5.3.290.0130.00613.09
5.3.280.0140.00412.99
5.3.270.0120.00713.10
5.3.260.0140.00412.97
5.3.250.0100.00713.05
5.3.240.0140.00313.04
5.3.230.0120.00713.05
5.3.220.0130.00612.87
5.3.210.0180.00612.87
5.3.200.0150.00612.89
5.3.190.0150.00512.91
5.3.180.0150.00713.06
5.3.170.0150.00513.10
5.3.160.0110.00713.10
5.3.150.0140.00613.06
5.3.140.0200.00513.07
5.3.130.0160.00513.07
5.3.120.0110.00813.02
5.3.110.0120.01113.06
5.3.100.0190.00613.06
5.3.90.0130.00713.09
5.3.80.0110.00712.95
5.3.70.0170.00412.99
5.3.60.0140.00413.06
5.3.50.0110.00613.04
5.3.40.0130.00612.93
5.3.30.0090.00513.05
5.3.20.0080.00712.92
5.3.10.0090.00412.90
5.3.00.0100.00612.94
5.2.170.0080.00612.50
5.2.160.0050.00712.57
5.2.150.0040.01012.42
5.2.140.0100.00412.53
5.2.130.0110.00412.35
5.2.120.0080.00512.56
5.2.110.0090.00412.52
5.2.100.0070.00612.52
5.2.90.0060.00612.43
5.2.80.0090.00612.38
5.2.70.0090.00512.44
5.2.60.0100.00612.41
5.2.50.0120.00512.45
5.2.40.0070.00612.47
5.2.30.0090.00612.45
5.2.20.0110.00312.39
5.2.10.0090.00612.35
5.2.00.0090.00512.37
5.1.60.0100.00412.09
5.1.50.0070.00612.09
5.1.40.0070.00612.09
5.1.30.0130.00212.10
5.1.20.0120.00312.09
5.1.10.0050.00912.09
5.1.00.0100.00212.09
5.0.50.0060.00412.09
5.0.40.0080.00412.09
5.0.30.0040.00712.09
5.0.20.0070.00512.09
5.0.10.0070.00412.09
5.0.00.0080.00112.09
4.4.90.0040.00612.09
4.4.80.0060.00312.09
4.4.70.0070.00212.09
4.4.60.0040.00212.09
4.4.50.0070.00412.09
4.4.40.0040.00312.09
4.4.30.0060.00212.09
4.4.20.0050.00612.09
4.4.10.0020.00512.09
4.4.00.0050.00312.09
4.3.110.0060.00112.09
4.3.100.0040.00512.09
4.3.90.0050.00412.09
4.3.80.0050.00412.09
4.3.70.0050.00512.09
4.3.60.0070.00212.09
4.3.50.0060.00212.09
4.3.40.0040.00312.09
4.3.30.0060.00212.09
4.3.20.0060.00212.09
4.3.10.0070.00112.09
4.3.00.0060.00212.09

preferences:
74.05 ms | 3170 KiB | 5 Q