3v4l.org

run code in 300+ PHP versions simultaneously
<?php // input misspelled word $input = 'carrrot'; // array of words to check against $words = array('apple','pineapple','banana','orange', 'radish','carrot','pea','bean','potato'); // no shortest distance found, yet $shortest = -1; // loop through words to find the closest foreach ($words as $word) { // calculate the distance between the input word, // and the current word $lev = levenshtein($input, $word); // check for an exact match if ($lev == 0) { // closest word is this one (exact match) $closest = $word; $shortest = 0; // break out of the loop; we've found an exact match break; } // if this distance is less than the next found shortest // distance, OR if a next shortest word has not yet been found if ($lev <= $shortest || $shortest < 0) { // set the closest match, and shortest distance $closest = $word; $shortest = $lev; } } echo "Input word: $input\n"; if ($shortest == 0) { echo "Exact match found: $closest\n"; } else { echo $lev."\n"; echo "Did you mean: $closest?\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.3.60.0170.00318.22
8.3.50.0120.00721.92
8.3.40.0070.01118.63
8.3.30.0100.01019.06
8.3.20.0040.00420.17
8.3.10.0140.00322.13
8.3.00.0050.00322.39
8.2.180.0140.00316.63
8.2.170.0160.00322.96
8.2.160.0070.00720.89
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00719.36
8.2.110.0070.00422.02
8.2.100.0080.00417.72
8.2.90.0080.00019.00
8.2.80.0050.00317.97
8.2.70.0030.00617.50
8.2.60.0090.00318.03
8.2.50.0040.00418.07
8.2.40.0040.00418.16
8.2.30.0000.00718.12
8.2.20.0000.00717.73
8.2.10.0040.00417.75
8.2.00.0050.00317.67
8.1.280.0130.00725.92
8.1.270.0060.00322.23
8.1.260.0080.00026.35
8.1.250.0070.00028.09
8.1.240.0100.00023.97
8.1.230.0080.00319.23
8.1.220.0000.00817.78
8.1.210.0080.00018.77
8.1.200.0060.00317.35
8.1.190.0000.00817.30
8.1.180.0070.00018.60
8.1.170.0040.00418.63
8.1.160.0040.00421.90
8.1.150.0000.00718.70
8.1.140.0040.00417.50
8.1.130.0030.00317.64
8.1.120.0040.00417.49
8.1.110.0000.00817.46
8.1.100.0030.00517.52
8.1.90.0030.00317.36
8.1.80.0000.00717.38
8.1.70.0040.00417.40
8.1.60.0050.00317.59
8.1.50.0030.00517.55
8.1.40.0050.00217.43
8.1.30.0030.00617.59
8.1.20.0040.00417.59
8.1.10.0040.00417.55
8.1.00.0040.00417.43
8.0.300.0070.00018.77
8.0.290.0040.00417.18
8.0.280.0070.00018.42
8.0.270.0040.00417.14
8.0.260.0030.00316.78
8.0.250.0070.00316.84
8.0.240.0040.00417.00
8.0.230.0070.00016.86
8.0.220.0030.00316.78
8.0.210.0030.00316.89
8.0.200.0000.01016.89
8.0.190.0080.00017.03
8.0.180.0050.00316.92
8.0.170.0030.00516.90
8.0.160.0000.00716.95
8.0.150.0040.00416.95
8.0.140.0040.00316.74
8.0.130.0000.00613.32
8.0.120.0040.00416.74
8.0.110.0030.00416.79
8.0.100.0070.00016.95
8.0.90.0030.00616.89
8.0.80.0000.01516.89
8.0.70.0000.00716.89
8.0.60.0000.00816.84
8.0.50.0070.00016.77
8.0.30.0100.01217.11
8.0.20.0080.01117.40
8.0.10.0040.00416.96
8.0.00.0090.00916.78
7.4.330.0050.00015.00
7.4.320.0000.00716.61
7.4.300.0000.00616.51
7.4.290.0030.00316.50
7.4.280.0040.00416.58
7.4.270.0070.00016.60
7.4.260.0030.00316.52
7.4.250.0040.00416.49
7.4.240.0060.00116.55
7.4.230.0070.00016.36
7.4.220.0130.00416.64
7.4.210.0090.00716.62
7.4.200.0070.00016.57
7.4.190.0050.00216.68
7.4.160.0120.00616.32
7.4.150.0120.00617.40
7.4.140.0080.01217.86
7.4.130.0050.01316.51
7.4.120.0030.01316.49
7.4.110.0060.01116.51
7.4.100.0060.01216.47
7.4.90.0180.00316.43
7.4.80.0120.00819.39
7.4.70.0100.00916.45
7.4.60.0030.01916.54
7.4.50.0040.00416.25
7.4.40.0030.01422.77
7.4.30.0060.01016.48
7.4.00.0070.01015.06
7.3.330.0070.00013.21
7.3.320.0060.00013.22
7.3.310.0050.00216.39
7.3.300.0000.00616.39
7.3.290.0040.01116.26
7.3.280.0110.00716.33
7.3.270.0110.00617.40
7.3.260.0140.01016.37
7.3.250.0150.00616.50
7.3.240.0100.01016.28
7.3.230.0100.01016.48
7.3.210.0100.01016.64
7.3.200.0090.01219.39
7.3.190.0090.00916.42
7.3.180.0080.00816.68
7.3.170.0080.01216.44
7.3.160.0100.00616.66
7.3.120.0040.00915.01
7.3.110.0070.01114.71
7.3.100.0100.00314.86
7.3.90.0070.00714.63
7.3.80.0030.01314.86
7.3.70.0030.01014.91
7.3.60.0080.00814.57
7.3.50.0060.00614.91
7.3.40.0030.01414.94
7.3.30.0030.01214.79
7.3.20.0070.00716.74
7.3.10.0000.01016.75
7.3.00.0000.01516.73
7.2.330.0090.00916.68
7.2.320.0100.01316.76
7.2.310.0120.00616.73
7.2.300.0140.00716.75
7.2.290.0120.00816.50
7.2.250.0000.01915.32
7.2.240.0060.01014.98
7.2.230.0000.01215.18
7.2.220.0070.00714.78
7.2.210.0070.01014.66
7.2.200.0040.00714.97
7.2.190.0060.00615.08
7.2.180.0100.00615.03
7.2.170.0100.00315.12
7.2.00.0130.00319.34
7.1.330.0040.01115.95
7.1.320.0090.00615.91
7.1.310.0060.00615.97
7.1.300.0090.00615.86
7.1.290.0060.01015.91
7.1.280.0090.00615.85
7.1.270.0040.00715.64
7.1.260.0070.00715.68
7.1.70.0070.00717.21
7.1.60.0040.00816.96
7.1.50.0220.01334.92
7.1.00.0030.07722.36
7.0.200.0040.01116.85
7.0.140.0030.07021.99
7.0.60.0030.07019.94
7.0.50.0100.08017.79
7.0.40.0000.06320.10
7.0.30.0230.06320.20
7.0.20.0330.07020.20
7.0.10.0270.07320.00
7.0.00.0170.05720.19
5.6.280.0000.09720.89
5.6.210.0100.06320.62
5.6.200.0030.04018.08
5.6.190.0070.04320.77
5.6.180.4130.04320.43
5.6.170.0270.04020.46
5.6.160.0130.07720.50
5.6.150.0130.07718.12
5.6.140.0070.04018.16
5.6.130.0070.08718.22
5.6.120.0030.06021.03
5.6.110.0070.09020.97
5.6.100.0030.04021.11
5.6.90.0100.08321.13
5.6.80.0070.08320.40
5.6.70.0330.05720.39
5.5.350.0070.08020.37
5.5.340.0070.06717.97
5.5.330.0130.08020.22
5.5.320.0230.08320.18
5.5.310.0270.04720.17
5.5.300.0070.07718.02
5.5.290.0030.05317.97
5.5.280.0000.08320.77
5.5.270.0100.05320.79
5.5.260.0070.05020.88
5.5.250.0070.04020.46
5.5.240.0100.05320.13
5.4.450.0500.06019.41
5.4.440.0700.06319.24
5.4.430.0130.05319.63
5.4.420.0600.06019.46
5.4.410.0400.06019.51
5.4.400.0830.00018.64
5.4.390.0870.00018.78
5.4.380.0100.07018.59
5.4.370.0400.04718.54
5.4.360.0430.04718.47
5.4.350.0330.05018.50
5.4.340.0200.06018.47
5.4.320.0040.03912.46
5.4.310.0070.04612.45
5.4.300.0060.04112.45
5.4.290.0090.04512.45
5.4.280.0070.05612.35
5.4.270.0060.03712.35
5.4.260.0070.07018.72
5.4.250.0100.04718.91
5.4.240.0100.04719.02
5.4.230.0070.05318.64
5.4.220.0070.08018.83
5.4.210.0230.03718.83
5.4.200.0030.05718.79
5.4.190.0070.05019.00
5.4.180.0100.05018.92
5.4.170.0030.08018.79
5.4.160.0130.04718.86
5.4.150.0070.06018.63
5.4.140.0100.05016.29
5.4.130.0170.04316.27
5.4.120.0100.05016.48
5.4.110.0070.05316.48
5.4.100.0070.05316.44
5.4.90.0070.04716.34
5.4.80.0200.05316.41
5.4.70.0070.05316.48
5.4.60.0070.05016.23
5.4.50.0030.05016.46
5.4.40.0070.05716.44
5.4.30.0130.05316.32
5.4.20.0070.04716.22
5.4.10.0130.04716.39
5.4.00.0230.03715.71
5.3.290.0060.04012.80
5.3.280.0100.04714.43
5.3.270.0100.04714.62
5.3.260.0070.08014.70
5.3.250.0100.05014.44
5.3.240.0100.06014.46
5.3.230.0130.04314.69
5.3.220.0230.05314.42
5.3.210.0130.05314.48
5.3.200.0130.06014.45
5.3.190.0030.05714.57
5.3.180.0000.05714.71
5.3.170.0100.05714.58
5.3.160.0170.04014.53
5.3.150.0130.04314.66
5.3.140.0170.04314.61
5.3.130.0070.05314.56
5.3.120.0070.05314.46
5.3.110.0070.07314.54
5.3.100.0100.06014.13
5.3.90.0030.05314.03
5.3.80.0100.04714.04
5.3.70.0100.04713.96
5.3.60.0100.04714.09
5.3.50.0030.05313.72
5.3.40.0200.05714.00
5.3.30.0170.06013.91
5.3.20.0070.05313.41
5.3.10.0000.06013.65
5.3.00.0070.04713.55
5.2.170.0070.04010.98
5.2.160.0170.03311.14
5.2.150.0030.04711.23
5.2.140.0030.04311.16
5.2.130.0100.05311.20
5.2.120.0130.05011.20
5.2.110.0070.04011.00
5.2.100.0070.04011.12
5.2.90.0030.04011.05
5.2.80.0000.04311.11
5.2.70.0070.04011.10
5.2.60.0130.03311.05
5.2.50.0100.05310.78
5.2.40.0100.03310.84
5.2.30.0070.04310.74
5.2.20.0030.04010.87
5.2.10.0070.03710.85
5.2.00.0100.03310.94
5.1.60.0000.03710.25
5.1.50.0030.0339.93
5.1.40.0070.0309.82
5.1.30.0100.03010.42
5.1.20.0070.03710.31
5.1.10.0030.03310.32
5.1.00.0100.03010.04
5.0.50.0000.0308.61
5.0.40.0000.0308.47
5.0.30.0130.0338.19
5.0.20.0000.0308.24
5.0.10.0000.0308.25
5.0.00.0030.0538.26
4.4.90.0000.0236.90
4.4.80.0070.0276.90
4.4.70.0000.0236.90
4.4.60.0030.0206.90
4.4.50.0100.0136.90
4.4.40.0070.0306.90
4.4.30.0030.0306.90
4.4.20.0030.0206.90
4.4.10.0000.0236.90
4.4.00.0030.0306.90
4.3.110.0000.0236.90
4.3.100.0030.0176.90
4.3.90.0030.0276.90
4.3.80.0030.0306.90
4.3.70.0000.0236.90
4.3.60.0070.0276.90
4.3.50.0030.0206.90
4.3.40.0100.0276.90
4.3.30.0030.0206.90
4.3.20.0030.0206.90
4.3.10.0000.0236.90
4.3.00.0130.0209.30

preferences:
34.93 ms | 401 KiB | 5 Q