3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convert_number_to_words($number) { $hyphen = '-'; $conjunction = ' and '; $separator = ', '; $negative = 'negative '; $decimal = ' point '; $dictionary = array( 0 => 'zero', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen', 16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty', 30 => 'thirty', 40 => 'fourty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety', 100 => 'hundred', 1000 => 'thousand', 1000000 => 'million', 1000000000 => 'billion', 1000000000000 => 'trillion', 1000000000000000 => 'quadrillion', 1000000000000000000 => 'quintillion' ); if (!is_numeric($number)) { return false; } if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) { // overflow trigger_error( 'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX, E_USER_WARNING ); return false; } if ($number < 0) { return $negative . convert_number_to_words(abs($number)); } $string = $fraction = null; if (strpos($number, '.') !== false) { list($number, $fraction) = explode('.', $number); } switch (true) { case $number < 21: $string = $dictionary[$number]; break; case $number < 100: $tens = ((int) ($number / 10)) * 10; $units = $number % 10; $string = $dictionary[$tens]; if ($units) { $string .= $hyphen . $dictionary[$units]; } break; case $number < 1000: $hundreds = $number / 100; $remainder = $number % 100; $string = $dictionary[$hundreds] . ' ' . $dictionary[100]; if ($remainder) { $string .= $conjunction . convert_number_to_words($remainder); } break; default: $baseUnit = pow(1000, floor(log($number, 1000))); $numBaseUnits = (int) ($number / $baseUnit); $remainder = $number % $baseUnit; $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit]; if ($remainder) { $string .= $remainder < 100 ? $conjunction : $separator; $string .= convert_number_to_words($remainder); } break; } if (null !== $fraction && is_numeric($fraction)) { $string .= $decimal; $words = array(); foreach (str_split((string) $fraction) as $number) { $words[] = $dictionary[$number]; } $string .= implode(' ', $words); } return $string; }

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.0090.00616.38
8.3.50.0080.01217.20
8.3.40.0140.00318.45
8.3.30.0110.00318.72
8.3.20.0040.00418.57
8.3.10.0000.00820.20
8.3.00.0040.00417.38
8.2.180.0150.00616.75
8.2.170.0120.00322.96
8.2.160.0100.00322.12
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0100.00017.91
8.2.110.0090.00022.24
8.2.100.0070.00417.66
8.2.90.0050.00319.10
8.2.80.0040.00417.91
8.2.70.0040.00417.38
8.2.60.0050.00317.80
8.2.50.0080.00018.07
8.2.40.0080.00018.09
8.2.30.0040.00417.85
8.2.20.0040.00417.45
8.2.10.0030.00617.61
8.2.00.0000.00717.57
8.1.280.0120.00925.92
8.1.270.0040.00423.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00320.53
8.1.230.0070.00420.89
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0000.01217.25
8.1.190.0000.00817.41
8.1.180.0060.00318.10
8.1.170.0050.00318.76
8.1.160.0040.00418.70
8.1.150.0070.00018.55
8.1.140.0000.00817.37
8.1.130.0000.00717.74
8.1.120.0030.00417.29
8.1.110.0040.00417.36
8.1.100.0040.00417.30
8.1.90.0040.00417.42
8.1.80.0040.00417.32
8.1.70.0020.00517.38
8.1.60.0000.00917.38
8.1.50.0000.00717.39
8.1.40.0040.00417.45
8.1.30.0050.00217.45
8.1.20.0040.00417.39
8.1.10.0000.00717.43
8.1.00.0040.00417.21
8.0.300.0080.00019.77
8.0.290.0040.00416.63
8.0.280.0000.00718.36
8.0.270.0080.00017.04
8.0.260.0030.00316.61
8.0.250.0000.00916.93
8.0.240.0030.00616.82
8.0.230.0070.00016.85
8.0.220.0030.00316.83
8.0.210.0070.00016.79
8.0.200.0040.00416.73
8.0.190.0030.00316.93
8.0.180.0000.00816.83
8.0.170.0040.00416.77
8.0.160.0030.00416.78
8.0.150.0040.00416.70
8.0.140.0040.00416.84
8.0.130.0000.00613.23
8.0.120.0080.00016.80
8.0.110.0030.00316.82
8.0.100.0040.00416.64
8.0.90.0040.00416.80
8.0.80.0110.00616.87
8.0.70.0000.00816.70
8.0.60.0040.00416.77
8.0.50.0040.00416.84
8.0.30.0080.01116.96
8.0.20.0080.01317.11
8.0.10.0000.00816.97
8.0.00.0120.00816.74
7.4.330.0000.00512.76
7.4.320.0030.00316.56
7.4.300.0030.00316.41
7.4.290.0070.00016.36
7.4.280.0030.00616.36
7.4.270.0030.00316.54
7.4.260.0000.00613.17
7.4.250.0040.00416.30
7.4.240.0030.00316.42
7.4.230.0070.00016.50
7.4.220.0090.00616.41
7.4.210.0100.00716.52
7.4.200.0070.00016.27
7.4.190.0030.00316.67
7.4.160.0090.00616.38
7.4.150.0120.00616.43
7.4.140.0050.01416.26
7.4.130.0080.01016.44
7.4.120.0010.01516.39
7.4.110.0030.01316.31
7.4.100.0130.00616.63
7.4.90.0130.00316.33
7.4.80.0120.01116.42
7.4.70.0070.01516.38
7.4.60.0130.00316.48
7.4.50.0000.00616.11
7.4.40.0090.00616.39
7.4.30.0050.01116.49
7.4.00.0060.00915.05
7.3.330.0000.00613.17
7.3.320.0050.00013.18
7.3.310.0030.00316.23
7.3.300.0040.00416.23
7.3.290.0080.00616.18
7.3.280.0120.00816.24
7.3.270.0050.01116.27
7.3.260.0110.00716.36
7.3.250.0110.00816.30
7.3.240.0160.00016.41
7.3.230.0070.01016.44
7.3.210.0100.00616.21
7.3.200.0050.01319.39
7.3.190.0100.01016.41
7.3.180.0160.00016.57
7.3.170.0120.00916.46
7.3.160.0090.00616.28
7.3.120.0000.01414.47
7.3.110.0100.00614.57
7.3.100.0000.01214.87
7.3.90.0100.00714.70
7.3.80.0060.00914.55
7.3.70.0040.01114.45
7.3.60.0030.01014.57
7.3.50.0030.01014.50
7.3.40.0030.01314.58
7.3.30.0100.00314.63
7.3.20.0120.00315.98
7.3.10.0070.00716.28
7.3.00.0040.01116.54
7.2.330.0110.01116.64
7.2.320.0120.00916.22
7.2.310.0160.00916.32
7.2.300.0090.00916.34
7.2.290.0070.01016.47
7.2.240.0000.01814.79
7.2.230.0030.01415.08
7.2.220.0070.00714.68
7.2.210.0040.01114.86
7.2.200.0090.00314.99
7.2.190.0030.00914.86
7.2.180.0030.01015.02
7.2.170.0070.00714.69
7.2.160.0070.01014.39
7.2.150.0090.00616.54
7.2.140.0070.01016.80
7.2.130.0060.00916.70
7.2.120.0120.00316.75
7.2.110.0070.00716.78
7.2.100.0030.01016.70
7.2.90.0090.00616.56
7.2.80.0070.01016.74
7.2.70.0000.01416.39
7.2.60.0060.00816.79
7.2.50.0030.00916.62
7.2.40.0060.00616.76
7.2.30.0070.00716.61
7.2.20.0000.01516.60
7.2.10.0030.00716.48
7.2.00.0040.01417.92
7.1.330.0030.00715.41
7.1.320.0000.01515.23
7.1.310.0030.01315.80
7.1.300.0070.01015.46
7.1.290.0060.00915.34
7.1.280.0100.00615.13
7.1.270.0060.00915.46
7.1.260.0060.00615.27
7.1.250.0060.00615.64
7.1.100.0070.00318.08
7.1.70.0070.00016.94
7.1.60.0110.00719.40
7.1.50.0040.00716.82
7.1.00.0000.07722.33
7.0.200.0070.00016.57
7.0.140.0000.07022.09
7.0.120.0000.07721.96
7.0.60.0070.03720.05
7.0.50.0100.07017.91
7.0.40.0100.03720.14
7.0.30.0030.04320.18
7.0.20.0000.04720.10
7.0.10.0000.05020.18
7.0.00.0000.04320.10
5.6.280.0100.06720.88
5.6.210.0100.07320.51
5.6.200.0070.08718.20
5.6.190.0000.04720.62
5.6.180.0030.04020.51
5.6.170.0030.04020.33
5.6.160.0000.04320.62
5.6.150.0030.04020.34
5.6.140.0070.03720.52
5.6.130.0070.04320.32
5.6.120.0030.05020.51
5.6.110.0070.07720.39
5.6.100.0030.08020.39
5.6.90.0000.05720.54
5.6.80.0130.06719.56
5.6.70.0000.04319.54
5.6.60.0100.07719.70
5.6.50.0030.08319.79
5.6.40.0030.08319.88
5.6.30.0100.06719.88
5.6.20.0070.05719.79
5.6.10.0070.05019.85
5.6.00.0170.07019.76
5.5.350.0270.07720.50
5.5.340.0130.07017.95
5.5.330.0000.04320.25
5.5.320.0000.04320.29
5.5.310.0030.04020.21
5.5.300.0030.04020.21
5.5.290.0100.08020.18
5.5.280.0030.04719.98
5.5.270.0030.08020.11
5.5.260.0070.04319.98
5.5.250.0100.04320.02
5.5.240.0030.08319.68
5.5.230.0130.07719.58
5.5.220.0000.05319.35
5.5.210.0030.04719.58
5.5.200.0000.05719.36
5.5.190.0070.08019.66
5.5.180.0100.06719.47
5.5.160.0070.07319.64
5.5.150.0070.07019.67
5.5.140.0000.05319.42
5.5.130.0030.05719.47
5.5.120.0100.05319.32
5.5.110.0000.08019.51
5.5.100.0030.08019.46
5.5.90.0070.04019.39
5.5.80.0130.07019.48
5.5.70.0130.08019.21
5.5.60.0030.08319.41
5.5.50.0100.07719.27
5.5.40.0070.05019.28
5.5.30.0130.07719.48
5.5.20.0030.06019.42
5.5.10.0130.03719.31
5.5.00.0130.07319.25
5.4.450.0070.08019.47
5.4.440.0100.04319.20
5.4.430.0100.08019.19
5.4.420.0070.05019.40
5.4.410.0170.06719.05
5.4.400.0070.05719.21
5.4.390.0000.08019.12
5.4.380.0070.04319.14
5.4.370.0100.04018.95
5.4.360.0000.06019.24
5.4.350.0000.04718.84
5.4.340.0100.07719.16
5.4.320.0130.06718.84
5.4.310.0030.06718.85
5.4.300.0030.07319.14
5.4.290.0030.04319.21
5.4.280.0070.06719.04
5.4.270.0070.05318.97
5.4.260.0070.03319.24
5.4.250.0070.04319.23
5.4.240.0000.04318.86
5.4.230.0000.07718.84
5.4.220.0030.08019.11
5.4.210.0030.05319.14
5.4.200.0070.07719.23
5.4.190.0100.06318.84
5.4.180.0100.05019.00
5.4.170.0100.07718.86
5.4.160.0030.07018.90
5.4.150.0130.06018.96
5.4.140.0070.04716.43
5.4.130.0030.08316.49
5.4.120.0030.05016.39
5.4.110.0030.08016.55
5.4.100.0030.04016.39
5.4.90.0030.03716.39
5.4.80.0070.03316.40
5.4.70.0200.06016.29
5.4.60.0130.06316.39
5.4.50.0030.06016.44
5.4.40.0100.07716.28
5.4.30.0170.06716.27
5.4.20.0100.03016.27
5.4.10.0100.06716.37
5.4.00.0070.04015.88
5.3.290.0000.04714.70
5.3.280.0070.07714.61
5.3.270.0130.07314.64
5.3.260.0070.07314.77
5.3.250.0000.06014.64
5.3.240.0100.07014.64
5.3.230.0070.07314.51
5.3.220.0170.05714.74
5.3.210.0030.05014.51
5.3.200.0070.05014.74
5.3.190.0030.04014.60
5.3.180.0130.03014.73
5.3.170.0070.06014.48
5.3.160.0000.06714.64
5.3.150.0100.05714.73
5.3.140.0200.06314.57
5.3.130.0000.05314.46
5.3.120.0030.08014.63
5.3.110.0030.04314.57
5.3.100.0100.06714.07
5.3.90.0070.07314.10
5.3.80.0130.06314.12
5.3.70.0100.07013.99
5.3.60.0070.03714.06
5.3.50.0000.04713.89
5.3.40.0100.05013.89
5.3.30.0000.05313.99
5.3.20.0070.07713.66
5.3.10.0100.06713.73
5.3.00.0100.03013.67
5.2.170.0000.04711.21
5.2.160.0100.06011.19
5.2.150.0000.04011.09
5.2.140.0030.05311.18
5.2.130.0100.05711.13
5.2.120.0100.05311.10
5.2.110.0070.04711.08
5.2.100.0100.05711.13
5.2.90.0030.05311.16
5.2.80.0070.03311.05
5.2.70.0070.05011.18
5.2.60.0000.05011.08
5.2.50.0000.05011.11
5.2.40.0100.05010.91
5.2.30.0000.04310.95
5.2.20.0070.06011.03
5.2.10.0030.04310.94
5.2.00.0030.03010.79
5.1.60.0000.05010.04
5.1.50.0030.05010.04
5.1.40.0030.0479.92
5.1.30.0070.05710.33
5.1.20.0030.03710.39
5.1.10.0030.04310.14
5.1.00.0000.06310.24
5.0.50.0030.0378.56
5.0.40.0030.0238.37
5.0.30.0070.0638.37
5.0.20.0100.0378.37
5.0.10.0030.0308.37
5.0.00.0070.0438.37
4.4.90.0100.0278.37
4.4.80.0000.0378.37
4.4.70.0070.0338.37
4.4.60.0030.0338.37
4.4.50.0000.0338.37
4.4.40.0030.0508.37
4.4.30.0030.0338.37
4.4.20.0070.0308.37
4.4.10.0030.0338.37
4.4.00.0000.0478.37
4.3.110.0000.0408.37
4.3.100.0000.0378.37
4.3.90.0000.0338.37
4.3.80.0000.0578.37
4.3.70.0000.0378.37
4.3.60.0030.0308.37
4.3.50.0030.0338.37
4.3.40.0000.0478.37
4.3.30.0000.0308.37
4.3.20.0000.0278.37
4.3.10.0030.0238.37
4.3.00.0030.0308.37

preferences:
41.1 ms | 401 KiB | 5 Q