3v4l.org

run code in 300+ PHP versions simultaneously
<?php function validate_EAN13Barcode($barcode) { // check to see if barcode is 13 digits long if (!preg_match("/^[0-9]{13}$/", $barcode)) { return false; } $digits = $barcode; // 1. Add the values of the digits in the // even-numbered positions: 2, 4, 6, etc. $even_sum = $digits[1] + $digits[3] + $digits[5] + $digits[7] + $digits[9] + $digits[11]; // 2. Multiply this result by 3. $even_sum_three = $even_sum * 3; // 3. Add the values of the digits in the // odd-numbered positions: 1, 3, 5, etc. $odd_sum = $digits[0] + $digits[2] + $digits[4] + $digits[6] + $digits[8] + $digits[10]; // 4. Sum the results of steps 2 and 3. $total_sum = $even_sum_three + $odd_sum; // 5. The check character is the smallest number which, // when added to the result in step 4, produces a multiple of 10. $next_ten = (ceil($total_sum / 10)) * 10; $check_digit = $next_ten - $total_sum; // if the check digit and the last digit of the // barcode are OK return true; if ($check_digit == $digits[12]) { return true; } return false; } echo "ean valide : ".validate_EAN13Barcode(3001209537341)."";

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.01818.53
8.3.50.0090.00922.11
8.3.40.0140.00418.92
8.3.30.0070.00718.93
8.3.20.0040.00420.13
8.3.10.0080.00021.86
8.3.00.0080.00019.27
8.2.180.0120.00318.47
8.2.170.0110.00322.96
8.2.160.0140.00022.13
8.2.150.0000.00924.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.58
8.2.110.0060.01219.27
8.2.100.0060.00620.52
8.2.90.0070.00418.03
8.2.80.0030.00517.97
8.2.70.0000.00818.05
8.2.60.0050.00318.34
8.2.50.0040.00418.10
8.2.40.0040.00519.30
8.2.30.0080.00019.39
8.2.20.0040.00418.02
8.2.10.0000.00818.19
8.2.00.0050.00517.96
8.1.280.0070.00725.92
8.1.270.0040.00418.89
8.1.260.0000.01026.35
8.1.250.0080.00028.09
8.1.240.0030.00620.77
8.1.230.0040.00719.11
8.1.220.0050.00317.74
8.1.210.0050.00318.97
8.1.200.0100.00017.47
8.1.190.0040.00417.50
8.1.180.0060.00318.10
8.1.170.0080.00020.91
8.1.160.0000.00819.02
8.1.150.0020.00519.00
8.1.140.0020.00517.50
8.1.130.0000.00717.76
8.1.120.0070.00017.61
8.1.110.0040.00417.65
8.1.100.0040.00417.58
8.1.90.0070.00017.50
8.1.80.0080.00017.62
8.1.70.0070.00017.66
8.1.60.0030.00517.75
8.1.50.0000.00817.57
8.1.40.0040.00417.61
8.1.30.0000.00817.71
8.1.20.0040.00417.75
8.1.10.0050.00317.63
8.1.00.0040.00417.66
8.0.300.0030.00621.58
8.0.290.0000.00816.88
8.0.280.0000.00818.45
8.0.270.0070.00017.28
8.0.260.0000.00617.24
8.0.250.0030.00317.16
8.0.240.0080.00017.15
8.0.230.0040.00417.05
8.0.220.0000.00717.00
8.0.210.0040.00417.07
8.0.200.0050.00217.03
8.0.190.0070.00017.16
8.0.180.0040.00417.05
8.0.170.0030.00617.07
8.0.160.0020.00517.10
8.0.150.0040.00816.98
8.0.140.0040.00417.06
8.0.130.0000.00613.54
8.0.120.0000.00817.02
8.0.110.0080.00017.08
8.0.100.0040.00416.95
8.0.90.0070.00017.12
8.0.80.0070.01717.11
8.0.70.0050.00316.96
8.0.60.0040.00416.92
8.0.50.0000.00817.09
8.0.30.0110.01017.18
8.0.20.0080.01117.44
8.0.10.0040.00417.27
8.0.00.0080.01516.97
7.4.330.0000.00515.04
7.4.320.0000.00616.70
7.4.300.0060.00016.70
7.4.290.0030.00316.82
7.4.280.0060.00316.84
7.4.270.0000.00716.85
7.4.260.0000.01116.68
7.4.250.0040.00416.66
7.4.240.0040.00316.75
7.4.230.0030.00316.68
7.4.220.0060.01216.63
7.4.210.0030.01716.80
7.4.200.0030.00716.72
7.4.160.0140.00316.59
7.4.150.0030.01617.40
7.4.140.0060.01217.86
7.4.130.0050.01216.72
7.4.120.0100.00716.68
7.4.110.0030.01716.73
7.4.100.0140.00616.79
7.4.90.0070.01116.82
7.4.80.0100.00719.39
7.4.70.0100.01416.68
7.4.60.0130.00316.82
7.4.50.0040.00416.81
7.4.40.0060.01016.81
7.4.30.0070.01016.61
7.4.00.0060.01215.34
7.3.330.0000.00613.55
7.3.320.0000.00513.53
7.3.310.0030.00316.54
7.3.300.0030.00316.58
7.3.290.0060.00916.48
7.3.280.0060.01116.52
7.3.270.0090.00917.40
7.3.260.0140.00716.55
7.3.250.0100.00716.79
7.3.240.0000.01816.84
7.3.230.0140.00616.65
7.3.210.0090.00616.60
7.3.200.0120.00619.39
7.3.190.0180.00416.59
7.3.180.0080.00816.69
7.3.170.0140.00816.68
7.3.160.0100.00616.55
7.3.00.0060.00916.88
7.2.330.0090.00916.97
7.2.320.0070.01016.84
7.2.310.0130.00316.72
7.2.300.0070.01016.74
7.2.290.0130.00416.82
7.2.130.0070.01116.80
7.2.120.0090.00617.11
7.2.110.0140.00317.12
7.2.100.0060.01016.96
7.2.90.0040.01117.20
7.2.80.0060.00917.03
7.2.70.0090.00917.16
7.2.60.0070.00917.06
7.2.50.0070.01116.99
7.2.40.0130.01016.82
7.2.30.0130.00317.11
7.2.20.0100.00717.22
7.2.10.0110.00616.91
7.2.00.0080.00718.47
7.1.250.0060.00915.74
7.1.240.0030.01015.80
7.1.230.0100.00615.81
7.1.220.0170.00016.05
7.1.210.0080.00515.93
7.1.200.0070.00916.06
7.1.190.0060.01116.12
7.1.180.0170.00715.77
7.1.170.0110.00415.88
7.1.160.0060.00915.96
7.1.150.0090.01215.95
7.1.140.0100.00315.63
7.1.130.0070.00715.80
7.1.120.0030.01015.75
7.1.110.0130.00315.96
7.1.100.0010.00917.19
7.1.90.0100.01015.78
7.1.80.0110.00615.75
7.1.70.0080.00316.65
7.1.60.0140.00717.63
7.1.50.0100.01216.50
7.1.40.0120.00715.77
7.1.30.0080.00815.70
7.1.20.0130.00315.96
7.1.10.0170.00016.02
7.1.00.0090.04019.23
7.0.330.0100.00615.61
7.0.320.0050.00915.39
7.0.310.0080.00615.45
7.0.300.0120.00315.59
7.0.290.0030.00915.46
7.0.280.0160.00015.51
7.0.270.0060.01015.47
7.0.260.0070.01115.60
7.0.250.0150.00015.64
7.0.240.0100.00315.66
7.0.230.0080.00515.61
7.0.220.0040.00715.30
7.0.210.0160.00015.66
7.0.200.0060.00615.97
7.0.190.0060.00815.71
7.0.180.0120.00415.57
7.0.170.0090.00415.47
7.0.160.0130.00015.38
7.0.150.0120.00315.63
7.0.140.0060.03418.79
7.0.130.0190.00315.48
7.0.120.0100.00715.50
7.0.110.0120.00315.70
7.0.100.0100.00415.57
7.0.90.0090.00615.39
7.0.80.0080.00415.17
7.0.70.0070.01015.29
7.0.60.0090.04517.82
7.0.50.0080.04516.85
7.0.40.0090.04316.94
7.0.30.0210.03816.92
7.0.20.0190.04016.95
7.0.10.0120.02116.92
7.0.00.0070.03716.89
5.6.380.0080.00414.59
5.6.370.0040.00714.51
5.6.360.0030.01014.76
5.6.350.0060.00614.38
5.6.340.0090.00414.31
5.6.330.0000.01314.58
5.6.320.0060.00914.44
5.6.310.0110.00314.41
5.6.300.0040.00813.84
5.6.290.0070.00314.21
5.6.280.0000.04417.85
5.6.270.0120.00014.69
5.6.260.0040.00414.75
5.6.250.0050.00914.21
5.6.240.0050.00514.56
5.6.230.0030.01014.21
5.6.220.0130.00014.17
5.6.210.0120.03217.48
5.6.200.0150.03816.34
5.6.190.0030.04917.43
5.6.180.0230.02817.21
5.6.170.0280.03017.25
5.6.160.0120.03417.39
5.6.150.0170.03516.22
5.6.140.0090.04316.21
5.6.130.0100.04216.34
5.6.120.0080.04617.60
5.6.110.0060.04717.55
5.6.100.0090.03917.62
5.6.90.0090.04317.77
5.6.80.0050.04517.27
5.6.70.0080.01214.14
5.6.60.0140.00814.45
5.6.50.0140.00914.39
5.6.40.0110.01114.20
5.6.30.0060.01414.29
5.6.20.0140.00814.28
5.6.10.0100.01414.43
5.6.00.0110.00614.23
5.5.380.0100.00010.90
5.5.370.0070.00210.96
5.5.360.0050.00511.04
5.5.350.0130.03915.77
5.5.340.0050.04314.56
5.5.330.0060.03815.51
5.5.320.0150.02115.74
5.5.310.0210.04015.89
5.5.300.0080.03014.51
5.5.290.0060.02214.77
5.5.280.0020.03015.92
5.5.270.0060.03016.03
5.5.260.0080.04015.92
5.5.250.0050.02815.80
5.5.240.0130.02115.71
5.5.230.0080.00511.34
5.5.220.0060.00911.32
5.5.210.0060.00811.26
5.5.200.0140.00311.30
5.5.190.0040.01111.05
5.5.180.0110.00011.33
5.5.170.0120.00411.17
5.5.160.0050.00511.19
5.5.150.0050.00511.21
5.5.140.0000.01011.12
5.5.130.0040.00411.17
5.5.120.0070.00411.11
5.5.110.0040.00711.17
5.5.100.0060.00311.12
5.5.90.0000.01111.20
5.5.80.0040.00411.26
5.5.70.0060.00610.91
5.5.60.0030.00610.90
5.5.50.0000.01011.02
5.5.40.0030.00610.90
5.5.30.0080.00411.27
5.5.20.0100.00311.07
5.5.10.0060.00611.25
5.5.00.0060.00911.27
5.4.450.2070.02615.26
5.4.440.2030.02015.14
5.4.430.1920.02415.52
5.4.420.1770.02015.08
5.4.410.1820.02215.40
5.4.400.2000.02515.20
5.4.390.1980.02015.11
5.4.380.2000.02415.17
5.4.370.1770.02215.13
5.4.360.1770.02415.09
5.4.350.1930.02215.01
5.4.340.2090.02015.27
5.4.330.0030.00711.05
5.4.320.1870.02315.01
5.4.310.1730.02015.17
5.4.300.1870.02114.99
5.4.290.1790.02015.25
5.4.280.1940.02015.01
5.4.270.2040.02115.16
5.4.260.1950.02014.88
5.4.250.1900.02115.12
5.4.240.1890.01615.07
5.4.230.2050.02415.22
5.4.220.1560.01915.10
5.4.210.1750.02115.03
5.4.200.1780.02314.96
5.4.190.1720.02014.99
5.4.180.2080.02715.09
5.4.170.1670.02315.01
5.4.160.1930.02215.00
5.4.150.1930.01815.11
5.4.140.1930.01813.82
5.4.130.2200.02213.65
5.4.120.2220.02513.62
5.4.110.2000.02313.74
5.4.100.2220.02413.84
5.4.90.2130.02013.75
5.4.80.1850.01913.84
5.4.70.1870.02213.91
5.4.60.2050.02013.82
5.4.50.1880.02013.79
5.4.40.1230.02313.68
5.4.30.1900.02213.65
5.4.20.1770.01913.70
5.4.10.1880.01913.78
5.4.00.1730.02213.50
5.3.290.1780.02212.82
5.3.280.1850.02212.75
5.3.270.1900.02712.87
5.3.260.1940.02012.73
5.3.250.1980.02712.75
5.3.240.1880.02912.71
5.3.230.2150.02512.73
5.3.220.2230.02012.79
5.3.210.2120.02612.69
5.3.200.2250.02012.81
5.3.190.2250.01712.69
5.3.180.2000.02012.84
5.3.170.2150.02312.75
5.3.160.1730.01812.73
5.3.150.1960.03112.68
5.3.140.1820.02012.68
5.3.130.1930.02112.72
5.3.120.1770.02312.67
5.3.110.1680.01812.75
5.3.100.1890.02212.55
5.3.90.1870.02212.50
5.3.80.1920.02212.54
5.3.70.1980.02212.42
5.3.60.2040.02012.46
5.3.50.1920.02112.38
5.3.40.1900.02312.43
5.3.30.1840.01512.36
5.3.20.2100.02612.37
5.3.10.1970.01812.26
5.3.00.2020.02012.23
5.2.170.1520.01811.97
5.2.160.1530.01811.97
5.2.150.1650.01611.97
5.2.140.1520.01511.97
5.2.130.1410.01311.97
5.2.120.1670.01411.97
5.2.110.1580.01911.97
5.2.100.1610.01711.97
5.2.90.1600.01511.97
5.2.80.1670.01811.97
5.2.70.1450.01711.97
5.2.60.1450.02011.97
5.2.50.1470.02111.97
5.2.40.1300.02111.97
5.2.30.1300.02111.97
5.2.20.1320.01611.97
5.2.10.1220.01511.97
5.2.00.1300.01611.97
5.1.60.1180.01511.97
5.1.50.1380.01311.97
5.1.40.1360.00811.97
5.1.30.1300.01411.97
5.1.20.1340.01311.97
5.1.10.1360.01511.97
5.1.00.1250.01311.97
5.0.50.0440.01711.97
5.0.40.0650.00911.97
5.0.30.0760.01811.97
5.0.20.0850.01411.97
5.0.10.0930.01011.97
5.0.00.0720.01711.97
4.4.90.0650.00911.97
4.4.80.0840.00811.97
4.4.70.0610.01011.97
4.4.60.0600.00911.97
4.4.50.0680.00911.97
4.4.40.0580.01411.97
4.4.30.0810.00911.97
4.4.20.0810.00811.97
4.4.10.0760.01111.97
4.4.00.0750.01311.97
4.3.110.0600.01011.97
4.3.100.0780.01111.97
4.3.90.0680.01111.97
4.3.80.0850.01411.97
4.3.70.0890.00711.97
4.3.60.0780.00911.97
4.3.50.0920.00711.26
4.3.40.0730.01411.26
4.3.30.0520.01211.26
4.3.20.0490.01211.26
4.3.10.0420.00811.26
4.3.00.0390.00711.26

preferences:
73.71 ms | 401 KiB | 5 Q