3v4l.org

run code in 300+ PHP versions simultaneously
<?php function intvaljunk($string) { $boolSignedNegative = false; $intIntStart = null; $intIntEnd = null; foreach (str_split($string) as $index => $char) { if (is_numeric($char)) { $boolSignedNegative = ( $boolSignedNegative === false && $index > 0 && is_null($intIntStart) && $string[$index - 1] === '-' ? true : $boolSignedNegative ); $intIntStart = is_null($intIntStart) ? $index : $intIntStart; $intIntEnd = is_null($intIntStart) ? $intIntEnd : $index; } else if (!is_null($intIntStart) && !is_null($intIntStart)) { break; } } return ( !is_null($intIntStart) && !is_null($intIntStart) ? intval(($boolSignedNegative ? '-' : '') . substr($string, $intIntStart, ($intIntEnd - $intIntStart) + 1)) : null ); } $signed_number_strings = ["--1", "---33", "+-444"]; foreach ($signed_number_strings as $string) { var_dump(intvaljunk($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.5.30.0080.00819.69
8.5.20.0090.00819.35
8.5.10.0110.00616.72
8.5.00.0140.00720.02
8.4.180.0150.00821.43
8.4.170.0120.01023.57
8.4.160.0140.00823.92
8.4.150.0080.00416.85
8.4.140.0110.01017.64
8.4.130.0110.01017.77
8.4.120.0150.00520.52
8.4.110.0070.00818.76
8.4.100.0100.00919.15
8.4.90.0120.00822.32
8.4.80.0120.00819.16
8.4.70.0110.00518.82
8.4.60.0120.00818.60
8.4.50.0110.00818.85
8.4.40.0090.01020.34
8.4.30.0140.00717.80
8.4.20.0070.01320.50
8.4.10.0060.00317.83
8.3.300.0210.01018.35
8.3.290.0100.00920.95
8.3.280.0120.00918.53
8.3.270.0100.00916.57
8.3.260.0140.00516.40
8.3.250.0100.00918.66
8.3.240.0140.00516.51
8.3.230.0130.00616.26
8.3.220.0120.00618.94
8.3.210.0060.00716.57
8.3.200.0060.00216.57
8.3.190.0050.00417.11
8.3.180.0110.00718.90
8.3.170.0150.00316.55
8.3.160.0060.00317.21
8.3.150.0110.00718.74
8.3.140.0070.00719.05
8.3.130.0050.00318.28
8.3.120.0030.00618.82
8.3.110.0030.00620.94
8.3.100.0080.00024.06
8.3.90.0070.00326.77
8.3.80.0060.00316.38
8.3.70.0070.00716.75
8.3.60.0090.01218.27
8.3.50.0120.00618.24
8.3.40.0070.00718.84
8.3.30.0040.01118.57
8.3.20.0080.00020.65
8.3.10.0040.00421.74
8.3.00.0040.00423.66
8.2.300.0130.00822.04
8.2.290.0050.00618.84
8.2.280.0150.00818.55
8.2.270.0090.00918.17
8.2.260.0090.00916.89
8.2.250.0040.00418.27
8.2.240.0000.00818.84
8.2.230.0110.00022.58
8.2.220.0050.00537.54
8.2.210.0040.01126.77
8.2.200.0070.00718.25
8.2.190.0150.00617.00
8.2.180.0100.00725.92
8.2.170.0120.00919.14
8.2.160.0070.01022.96
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00420.48
8.2.120.0080.00026.35
8.2.110.0040.00420.77
8.2.100.0000.01117.84
8.2.90.0050.00318.28
8.2.80.0050.00318.03
8.2.70.0040.00418.01
8.2.60.0040.00418.16
8.2.50.0000.00818.10
8.2.40.0050.00319.05
8.2.30.0000.00719.38
8.2.20.0050.00218.14
8.2.10.0070.00019.38
8.2.00.0080.00018.19
8.1.340.0130.00919.92
8.1.330.0110.00818.65
8.1.320.0110.01016.19
8.1.310.0030.00716.77
8.1.300.0120.00420.08
8.1.290.0030.00630.84
8.1.280.0110.00725.92
8.1.270.0080.00023.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.01017.39
8.1.230.0110.00020.94
8.1.220.0000.00817.75
8.1.210.0000.00820.95
8.1.200.0060.00317.23
8.1.190.0040.00417.09
8.1.180.0030.00518.10
8.1.170.0040.00418.71
8.1.160.0050.00218.86
8.1.150.0050.00218.77
8.1.140.0040.00418.92
8.1.130.0040.00420.15
8.1.120.0030.00517.38
8.1.110.0000.00717.35
8.1.100.0040.00417.36
8.1.90.0080.00317.39
8.1.80.0090.00017.49
8.1.70.0000.00717.38
8.1.60.0040.00417.58
8.1.50.0030.00517.49
8.1.40.0090.00017.50
8.1.30.0050.00317.66
8.1.20.0030.00717.57
8.1.10.0040.00417.46
8.1.00.0040.00417.47
8.0.300.0080.00019.64
8.0.290.0030.00616.75
8.0.280.0070.00018.41
8.0.270.0030.00317.18
8.0.260.0040.00418.38
8.0.250.0070.00016.83
8.0.240.0000.00816.98
8.0.230.0030.00316.85
8.0.220.0070.00016.94
8.0.210.0030.00316.94
8.0.200.0030.00316.84
8.0.190.0040.00416.91
8.0.180.0030.00516.83
8.0.170.0060.00316.89
8.0.160.0080.00016.84
8.0.150.0000.00816.84
8.0.140.0000.00816.90
8.0.130.0000.00513.41
8.0.120.0030.00616.90
8.0.110.0040.00416.94
8.0.100.0040.00416.80
8.0.90.0040.00416.93
8.0.80.0110.00616.93
8.0.70.0050.00316.85
8.0.60.0000.00816.70
8.0.50.0070.00016.77
8.0.30.0100.00817.20
8.0.20.0090.01117.40
8.0.10.0070.00016.86
8.0.00.0090.01416.80
7.4.330.0000.00515.55
7.4.320.0000.00716.46
7.4.300.0060.00016.62
7.4.290.0000.00716.54
7.4.280.0040.00416.49
7.4.270.0040.00416.62
7.4.260.0030.00316.48
7.4.250.0050.00216.62
7.4.240.0030.00516.46
7.4.230.0050.00316.64
7.4.220.0050.00316.31
7.4.210.0130.00416.59
7.4.200.0030.00316.64
7.4.160.0100.00816.55
7.4.140.0110.01217.86
7.4.130.0000.02316.66
7.4.120.0090.00916.71
7.4.110.0070.01116.34
7.4.100.0120.01216.58
7.4.90.0130.00516.46
7.4.80.0060.01419.39
7.4.70.0080.00816.59
7.4.60.0140.00316.60
7.4.50.0030.01016.68
7.4.40.0090.00616.52
7.4.10.0070.01014.96
7.4.00.0060.00914.89
7.3.330.0060.00013.16
7.3.320.0050.00013.31
7.3.310.0070.00016.39
7.3.300.0000.00716.29
7.3.290.0040.00416.29
7.3.280.0050.01216.38
7.3.260.0110.00816.53
7.3.240.0120.01016.48
7.3.230.0160.00616.36
7.3.210.0120.00816.42
7.3.200.0140.00916.34
7.3.190.0070.01616.25
7.3.180.0090.00616.36
7.3.170.0030.01416.32
7.3.160.0090.01216.51
7.3.130.0060.00614.79
7.3.120.0080.00815.09
7.3.110.0030.01214.76
7.3.100.0080.00714.71
7.3.90.0060.00614.88
7.3.80.0070.00814.75
7.3.70.0070.00514.99
7.3.60.0070.00714.86
7.3.50.0060.01014.70
7.3.40.0050.00814.78
7.3.30.0020.01214.91
7.3.20.0070.00916.71
7.3.10.0260.01016.05
7.3.00.0260.00115.96
7.2.330.0090.01216.60
7.2.320.0120.00616.83
7.2.310.0100.00716.43
7.2.300.0070.01016.53
7.2.290.0190.00316.70
7.2.260.0070.01114.88
7.2.250.0020.01415.02
7.2.240.0030.01415.01
7.2.230.0050.00915.15
7.2.220.0050.00914.96
7.2.210.0090.00615.17
7.2.200.0090.00815.18
7.2.190.0090.00815.09
7.2.180.0050.00715.03
7.2.170.0050.00915.13
7.2.160.0030.01315.11
7.2.150.0050.00517.11
7.2.140.0100.00716.96
7.2.130.0230.00916.10
7.2.120.0400.00315.97
7.2.110.0260.01215.96
7.2.100.0340.00915.99
7.2.90.0430.00215.90
7.2.80.0080.01015.82
7.2.70.0460.00416.01
7.2.60.0240.00816.10
7.2.50.0100.01015.88
7.2.40.0170.00715.94
7.2.30.0290.01216.02
7.2.20.0280.01216.05
7.2.10.0300.00715.87
7.2.00.0270.00816.04
7.1.330.0040.01015.93
7.1.320.0090.00515.95
7.1.310.0110.00315.67
7.1.300.0070.00515.87
7.1.290.0050.00715.73
7.1.280.0120.00515.82
7.1.270.0080.00815.85
7.1.260.0050.00915.79
7.1.250.0100.01015.07
7.1.240.0060.00315.87
7.1.230.0050.00516.00
7.1.220.0080.00415.99
7.1.210.0030.01015.69
7.1.200.0030.00815.55
7.1.190.0070.00715.78
7.1.180.0080.00815.86
7.1.170.0070.01115.54
7.1.160.0090.00915.70
7.1.150.0040.00815.91
7.1.140.0040.00815.89
7.1.130.0040.00415.83
7.1.120.0000.01415.69
7.1.110.0000.01215.96
7.1.100.0070.00715.66
7.1.90.0030.00716.00
7.1.80.0040.01215.96
7.1.70.0050.00815.99
7.1.60.0040.00815.85
7.1.50.0030.01415.88
7.1.40.0070.01115.71
7.1.30.0030.01115.88
7.1.20.0060.00315.84
7.1.10.0080.00415.65
7.1.00.0070.00315.56

preferences:
113.18 ms | 1611 KiB | 5 Q