3v4l.org

run code in 300+ PHP versions simultaneously
<?php // input misspelled word $input = 'carriotot'; // 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 $lev."\n"; 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.0040.01118.30
8.3.50.0230.01221.93
8.3.40.0070.00718.79
8.3.30.0100.00718.79
8.3.20.0040.00420.18
8.3.10.0040.00422.05
8.3.00.0170.00322.43
8.2.180.0110.00716.75
8.2.170.0090.00922.96
8.2.160.0140.00020.93
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0050.00517.63
8.2.110.0040.00422.24
8.2.100.0070.00719.57
8.2.90.0000.00719.05
8.2.80.0000.00817.97
8.2.70.0030.00517.62
8.2.60.0000.01017.93
8.2.50.0000.00818.07
8.2.40.0040.00418.34
8.2.30.0030.00618.14
8.2.20.0070.00017.73
8.2.10.0000.00717.77
8.2.00.0090.00017.64
8.1.280.0100.00725.92
8.1.270.0060.00322.04
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0060.00323.88
8.1.230.0110.00019.16
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0060.00317.23
8.1.190.0080.00017.43
8.1.180.0040.00418.79
8.1.170.0040.00418.70
8.1.160.0070.00022.04
8.1.150.0030.00618.70
8.1.140.0040.00417.34
8.1.130.0050.00217.77
8.1.120.0000.00717.52
8.1.110.0050.00317.36
8.1.100.0000.00717.36
8.1.90.0030.00517.46
8.1.80.0050.00317.52
8.1.70.0030.00317.46
8.1.60.0040.00417.45
8.1.50.0030.00517.57
8.1.40.0040.00417.54
8.1.30.0050.00317.50
8.1.20.0030.00617.69
8.1.10.0040.00417.43
8.1.00.0000.00717.48
8.0.300.0000.00718.77
8.0.290.0050.00216.90
8.0.280.0000.00718.46
8.0.270.0040.00417.27
8.0.260.0000.00716.91
8.0.250.0040.00416.85
8.0.240.0040.00416.95
8.0.230.0000.00716.99
8.0.220.0000.00716.95
8.0.210.0000.00716.93
8.0.200.0000.01116.83
8.0.190.0030.00416.93
8.0.180.0070.00016.99
8.0.170.0000.00716.93
8.0.160.0060.00316.93
8.0.150.0040.00416.74
8.0.140.0000.00716.78
8.0.130.0000.00513.33
8.0.120.0080.00016.87
8.0.110.0030.00316.88
8.0.100.0030.00516.94
8.0.90.0040.00416.88
8.0.80.0120.00316.90
8.0.70.0040.00416.90
8.0.60.0070.00016.96
8.0.50.0040.00416.71
8.0.30.0130.00517.32
8.0.20.0080.01117.43
8.0.10.0040.00416.91
8.0.00.0080.01016.77
7.4.330.0050.00015.00
7.4.320.0030.00316.50
7.4.300.0000.00616.59
7.4.290.0030.00316.45
7.4.280.0030.00316.56
7.4.270.0080.00016.66
7.4.260.0030.00316.50
7.4.250.0040.00416.50
7.4.240.0020.00616.51
7.4.230.0030.00316.27
7.4.220.0120.00616.55
7.4.210.0040.01216.62
7.4.200.0000.00716.43
7.4.190.0000.00816.68
7.4.160.0080.00816.80
7.4.150.0160.00017.40
7.4.140.0110.00817.86
7.4.130.0080.01016.48
7.4.120.0090.01116.54
7.4.110.0090.00916.57
7.4.100.0140.00316.42
7.4.90.0060.01016.58
7.4.80.0070.01119.39
7.4.70.0150.00216.64
7.4.60.0110.00616.58
7.4.50.0030.00616.45
7.4.40.0060.01122.77
7.4.30.0130.00916.58
7.4.00.0090.00314.82
7.3.330.0060.00013.14
7.3.320.0050.00013.25
7.3.310.0040.00416.38
7.3.300.0080.00016.15
7.3.290.0100.01016.36
7.3.280.0060.01216.35
7.3.270.0130.00817.40
7.3.260.0080.01516.62
7.3.250.0110.00916.46
7.3.240.0070.01116.36
7.3.230.0160.00316.39
7.3.210.0100.00616.50
7.3.200.0120.00919.39
7.3.190.0100.01216.53
7.3.180.0090.00616.47
7.3.170.0060.01016.69
7.3.160.0130.00316.53
7.3.120.0070.01014.73
7.2.330.0070.01016.57
7.2.320.0210.00316.79
7.2.310.0090.00916.64
7.2.300.0150.00916.54
7.2.290.0130.00316.84
7.2.60.0040.01116.57
7.2.00.0040.01119.30
7.1.200.0040.00815.91
7.1.100.0060.00618.33
7.1.70.0000.01617.20
7.1.60.0130.01019.82
7.1.50.0250.00934.72
7.1.00.0070.07322.25
7.0.200.0060.00616.69
7.0.140.0030.07321.92
7.0.60.0000.08719.93
7.0.50.0200.07017.89
7.0.40.0100.08020.20
7.0.30.0300.06020.08
7.0.20.0270.05020.31
7.0.10.0230.08720.21
7.0.00.0100.09020.00
5.6.280.0100.06721.10
5.6.210.0130.04320.45
5.6.200.0030.04018.18
5.6.190.0170.07320.42
5.6.180.4300.04020.49
5.6.170.0370.04320.38
5.6.160.0200.07020.50
5.6.150.0130.07718.18
5.6.140.0100.07718.11
5.6.130.0100.04718.10
5.6.120.0070.08721.03
5.6.110.0070.06021.01
5.6.100.0100.03320.97
5.6.90.0130.06321.02
5.6.80.0100.05720.53
5.6.70.0330.07020.49
5.5.350.0130.08020.46
5.5.340.0070.04018.02
5.5.330.0070.05320.40
5.5.320.0270.06320.31
5.5.310.0370.04320.26
5.5.300.0070.04318.02
5.5.290.0170.07017.87
5.5.280.0100.08320.96
5.5.270.0100.05720.84
5.5.260.0070.05720.76
5.5.250.0030.04020.64
5.5.240.0130.07720.26
5.4.450.0800.05319.49
5.4.440.0670.06019.41
5.4.430.0170.05019.57
5.4.420.0100.05319.27
5.4.410.0670.04319.00
5.4.400.0830.00018.52
5.4.390.0930.00018.63
5.4.380.0230.05318.60
5.4.370.0230.05018.68
5.4.360.0430.03718.66
5.4.350.0370.05318.49
5.4.340.0370.04718.50
5.4.320.0100.03312.46
5.4.310.0100.04812.45
5.4.300.0090.04412.46
5.4.290.0060.03712.45
5.4.280.0060.03812.35
5.4.270.0070.03612.35
5.4.260.0030.05318.73
5.4.250.0100.05718.88
5.4.240.0130.06719.03
5.4.230.0070.05318.89
5.4.220.0100.06318.94
5.4.210.0000.08018.88
5.4.200.0100.05018.91
5.4.190.0030.05718.91
5.4.180.0070.05318.85
5.4.170.0030.05718.87
5.4.160.0100.06718.81
5.4.150.0100.05018.63
5.4.140.0100.05016.50
5.4.130.0170.06016.23
5.4.120.0170.05716.25
5.4.110.0100.05316.24
5.4.100.0000.05716.31
5.4.90.0130.04316.25
5.4.80.0170.04316.47
5.4.70.0130.06716.34
5.4.60.0100.05016.33
5.4.50.0130.07016.19
5.4.40.0100.04716.55
5.4.30.0030.05016.16
5.4.20.0130.05716.40
5.4.10.0100.05316.41
5.4.00.0100.04715.74
5.3.290.0040.04512.80
5.3.280.0070.05314.61
5.3.270.0170.04314.61
5.3.260.0070.05714.63
5.3.250.0030.05314.48
5.3.240.0100.05014.31
5.3.230.0130.05714.75
5.3.220.0000.05714.44
5.3.210.0030.05714.44
5.3.200.0070.07314.49
5.3.190.0130.05314.57
5.3.180.0130.04314.42
5.3.170.0070.05314.56
5.3.160.0170.06314.61
5.3.150.0030.05314.58
5.3.140.0030.06314.57
5.3.130.0130.04714.54
5.3.120.0100.07314.56
5.3.110.0100.05014.56
5.3.100.0100.05014.03
5.3.90.0100.05013.88
5.3.80.0130.04313.93
5.3.70.0100.04713.88
5.3.60.0100.04714.02
5.3.50.0130.06013.79
5.3.40.0100.05013.98
5.3.30.0100.04313.93
5.3.20.0100.05013.84
5.3.10.0130.06713.54
5.3.00.0030.05313.64
5.2.170.0030.04311.08
5.2.160.0130.04010.91
5.2.150.0100.03711.05
5.2.140.0170.04311.16
5.2.130.0100.05010.99
5.2.120.0130.03311.13
5.2.110.0030.05711.25
5.2.100.0100.03711.25
5.2.90.0070.06011.09
5.2.80.0030.04310.86
5.2.70.0130.03711.09
5.2.60.0070.04311.09
5.2.50.0070.04010.81
5.2.40.0070.03710.76
5.2.30.0100.05310.86
5.2.20.0030.04311.00
5.2.10.0200.03310.86
5.2.00.0100.04310.71
5.1.60.0100.0409.84
5.1.50.0170.0339.96
5.1.40.0100.0279.90
5.1.30.0030.04010.43
5.1.20.0070.05310.44
5.1.10.0230.03310.00
5.1.00.0000.05310.00
5.0.50.0070.0238.47
5.0.40.0000.0408.48
5.0.30.0070.0408.32
5.0.20.0070.0238.25
5.0.10.0000.0308.02
5.0.00.0000.0478.22
4.4.90.0000.0306.90
4.4.80.0030.0306.90
4.4.70.0070.0206.90
4.4.60.0030.0236.90
4.4.50.0030.0206.90
4.4.40.0030.0476.90
4.4.30.0000.0236.90
4.4.20.0070.0276.90
4.4.10.0000.0236.90
4.4.00.0030.0376.90
4.3.110.0000.0236.90
4.3.100.0000.0236.90
4.3.90.0070.0176.90
4.3.80.0100.0306.90
4.3.70.0070.0176.90
4.3.60.0000.0236.90
4.3.50.0000.0336.90
4.3.40.0030.0336.90
4.3.30.0030.0276.90
4.3.20.0030.0206.90
4.3.10.0000.0236.90
4.3.00.0100.0239.30

preferences:
58.62 ms | 401 KiB | 5 Q