3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isCorrect($string) { $len = strlen($string); $stack = array(); for( $i = 0; $i < $len; ++$i) { if ( $string[$i] == '(' ) array_push($stack, $string[$i]); elseif( $string[$i] == ')' ) { if ( empty($stack) === false ) array_pop($stack); else return false; } } return empty($stack); } $string = '())((()))'; var_dump(isCorrect($string)); //var_dump(isCorrect($string)); //var_dump(strlen($string) % 2); //assert(isCorrect('') === true); //assert(isCorrect('()') === true); //assert(isCorrect('{()}') === true); //assert(isCorrect('{()}{}') === true); //assert(isCorrect('(())') === true); //assert(isCorrect('{({({({()})})})}') === true); //assert(isCorrect('{(})') === false);

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.40.0070.01118.68
8.3.30.0030.01019.14
8.3.20.0070.00020.29
8.3.10.0040.00423.54
8.3.00.0080.00019.13
8.2.170.0100.01022.96
8.2.160.0120.00320.30
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0070.00026.16
8.2.120.0040.00422.18
8.2.110.0030.00619.27
8.2.100.0060.00617.72
8.2.90.0080.00019.23
8.2.80.0050.00317.97
8.2.70.0000.00817.50
8.2.60.0000.00817.80
8.2.50.0080.00018.10
8.2.40.0000.00819.88
8.2.30.0030.00717.97
8.2.20.0080.00017.68
8.2.10.0040.00418.05
8.2.00.0080.00017.71
8.1.270.0050.00323.97
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0030.00622.50
8.1.230.0040.00817.89
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0000.00817.23
8.1.180.0040.00418.10
8.1.170.0040.00418.63
8.1.160.0000.00722.01
8.1.150.0020.00518.75
8.1.140.0030.00617.37
8.1.130.0070.00017.89
8.1.120.0040.00417.31
8.1.110.0070.00017.31
8.1.100.0000.00717.48
8.1.90.0030.00317.53
8.1.80.0050.00317.45
8.1.70.0000.00717.41
8.1.60.0060.00317.61
8.1.50.0080.00017.54
8.1.40.0080.00017.52
8.1.30.0040.00417.60
8.1.20.0070.00017.54
8.1.10.0040.00417.61
8.1.00.0000.00717.37
8.0.300.0090.00019.65
8.0.290.0000.00916.58
8.0.280.0030.00318.38
8.0.270.0070.00017.25
8.0.260.0000.00717.18
8.0.250.0070.00016.84
8.0.240.0060.00016.91
8.0.230.0030.00616.92
8.0.220.0000.00716.80
8.0.210.0030.00316.79
8.0.200.0040.00416.79
8.0.190.0080.00016.88
8.0.180.0040.00416.74
8.0.170.0000.00816.74
8.0.160.0000.00816.84
8.0.150.0080.00016.66
8.0.140.0030.00516.71
8.0.130.0060.00013.30
8.0.120.0030.00616.68
8.0.110.0000.00716.91
8.0.100.0000.00716.91
8.0.90.0040.00416.78
8.0.80.0100.01016.88
8.0.70.0040.00416.84
8.0.60.0050.00216.77
8.0.50.0070.00016.91
8.0.30.0080.01116.93
8.0.20.0140.00917.40
8.0.10.0000.00716.79
8.0.00.0070.00916.72
7.4.330.0000.00415.02
7.4.320.0070.00016.55
7.4.300.0000.00616.48
7.4.290.0000.00716.60
7.4.280.0000.00916.48
7.4.270.0040.00416.62
7.4.260.0030.00316.60
7.4.250.0000.00716.61
7.4.240.0020.00516.57
7.4.230.0000.00716.40
7.4.220.0070.01016.61
7.4.210.0030.01016.55
7.4.200.0000.00716.53
7.4.160.0140.00716.43
7.4.150.0070.01117.40
7.4.140.0130.00817.86
7.4.130.0140.00416.48
7.4.120.0060.01016.41
7.4.110.0060.01116.40
7.4.100.0140.00316.48
7.4.90.0100.00716.38
7.4.80.0070.01019.39
7.4.70.0110.01116.72
7.4.60.0030.01316.49
7.4.50.0020.00216.37
7.4.40.0150.00316.27
7.4.30.0160.00916.23
7.4.10.0090.00915.17
7.4.00.0050.01114.78
7.3.330.0000.00513.36
7.3.320.0000.00513.40
7.3.310.0030.00616.22
7.3.300.0030.00316.34
7.3.290.0070.00716.35
7.3.280.0040.01116.36
7.3.270.0140.00817.40
7.3.260.0110.00616.55
7.3.250.0150.00816.50
7.3.240.0040.01316.50
7.3.230.0100.00716.52
7.3.210.0090.00916.48
7.3.200.0120.01219.39
7.3.190.0080.01216.28
7.3.180.0030.01416.61
7.3.170.0070.01016.36
7.3.160.0030.01316.32
7.3.130.0100.01014.73
7.3.120.0070.01115.03
7.3.110.0040.01114.82
7.3.100.0030.01014.88
7.3.90.0030.01014.78
7.3.80.0140.00414.52
7.3.70.0070.00714.84
7.3.60.0000.01314.52
7.3.50.0110.00014.72
7.3.40.0080.00014.67
7.3.30.0100.00714.70
7.3.20.0000.01316.42
7.3.10.0000.01316.63
7.3.00.0070.00316.67
7.2.330.0100.00716.80
7.2.320.0240.00316.60
7.2.310.0110.00716.75
7.2.300.0130.00316.55
7.2.290.0100.00716.66
7.2.260.0100.01015.20
7.2.250.0090.00914.92
7.2.240.0000.01514.85
7.2.230.0130.00714.88
7.2.220.0110.00715.28
7.2.210.0090.00915.16
7.2.200.0100.00715.13
7.2.190.0000.01715.02
7.2.180.0070.01014.77
7.2.170.0000.01415.00
7.2.160.0030.01314.95
7.2.150.0030.01316.64
7.2.140.0060.00617.04
7.2.130.0030.01216.73
7.2.120.0070.01016.87
7.2.110.0060.00316.63
7.2.100.0070.01016.86
7.2.90.0130.00316.78
7.2.80.0000.01416.89
7.2.70.0040.01117.13
7.2.60.0100.00717.05
7.2.50.0070.00717.14
7.2.40.0000.01416.74
7.2.30.0070.00716.62
7.2.20.0060.00616.71
7.2.10.0040.01516.96
7.2.00.0060.00818.22
7.1.330.0040.00815.98
7.1.320.0000.01215.91
7.1.310.0030.00915.76
7.1.300.0100.00916.02
7.1.290.0000.01415.53
7.1.280.0000.01415.86
7.1.270.0000.01515.95
7.1.260.0110.00315.62
7.1.250.0000.01615.70
7.1.240.0030.01415.65
7.1.230.0070.00715.58
7.1.220.0040.00715.58
7.1.210.0120.00315.40
7.1.200.0030.01015.72
7.1.190.0100.00315.77
7.1.180.0060.00615.74
7.1.170.0040.00415.87
7.1.160.0060.00915.81
7.1.150.0030.00815.87
7.1.140.0030.01015.58
7.1.130.0070.00715.57
7.1.120.0030.01015.54
7.1.110.0040.00715.87
7.1.100.0070.00716.98
7.1.90.0070.00715.55
7.1.80.0000.01115.84
7.1.70.0040.00516.33
7.1.60.0040.00617.39
7.1.50.0080.00916.34
7.1.40.0060.00615.86
7.1.30.0100.00315.78
7.1.20.0070.00715.41
7.1.10.0110.00315.61
7.1.00.0020.04419.00
7.0.330.0120.00615.27
7.0.320.0090.00615.43
7.0.310.0040.01115.60
7.0.300.0030.01415.29
7.0.290.0030.00815.51
7.0.280.0060.00615.48
7.0.270.0090.00615.39
7.0.260.0030.01015.43
7.0.250.0050.00315.16
7.0.240.0060.00615.38
7.0.230.0100.00615.39
7.0.220.0030.00915.49
7.0.210.0000.01215.57
7.0.200.0050.00516.19
7.0.190.0030.01315.56
7.0.180.0070.00715.55
7.0.170.0040.00415.22
7.0.160.0060.00615.33
7.0.150.0050.00815.23
7.0.140.0040.04218.71
7.0.130.0070.00715.46
7.0.120.0030.00715.42
7.0.110.0000.01115.30
7.0.100.0070.00715.20
7.0.90.0030.01315.57
7.0.80.0110.00415.48
7.0.70.0030.01215.34
7.0.60.0080.04517.53
7.0.50.0070.02616.71
7.0.40.0020.04716.81
7.0.30.0160.04516.91
7.0.20.0150.04516.88
7.0.10.0030.04116.88
7.0.00.0080.03116.76
5.6.400.0000.01514.64
5.6.390.0040.01414.23
5.6.380.0100.00314.52
5.6.370.0000.00914.62
5.6.360.0050.00514.54
5.6.350.0040.01114.12
5.6.340.0040.00814.71
5.6.330.0080.00314.35
5.6.320.0120.00014.28
5.6.310.0030.01314.36
5.6.300.0030.00513.98
5.6.290.0080.00614.24
5.6.280.0080.03617.75
5.6.270.0070.00714.44
5.6.260.0060.00614.25
5.6.250.0040.00814.54
5.6.240.0040.00414.32
5.6.230.0060.00614.30
5.6.220.0030.01014.25
5.6.210.0050.05017.56
5.6.200.0100.03816.16
5.6.190.0050.04517.32
5.6.180.0120.02317.45
5.6.170.0200.02517.45
5.6.160.0060.02617.31
5.6.150.0050.04016.27
5.6.140.0020.02616.14
5.6.130.0110.03616.25
5.6.120.0100.04517.71
5.6.110.0030.04517.64
5.6.100.0050.04717.72
5.6.90.0080.04417.57
5.6.80.0100.04117.31
5.6.70.2340.01917.34
5.6.60.0030.00714.27
5.6.50.0080.00413.98
5.6.40.0070.00314.22
5.6.30.0030.01314.29
5.6.20.0030.00714.47
5.6.10.0000.01214.02
5.6.00.0000.01414.56
5.5.380.0090.00314.46
5.5.370.0070.00314.20
5.5.360.0040.01114.51
5.5.350.0060.02517.36
5.5.340.0060.02316.19
5.5.330.0030.05317.48
5.5.320.0110.02317.20
5.5.310.0120.02317.19
5.5.300.0090.02216.18
5.5.290.0050.02716.00
5.5.280.0040.02517.52
5.5.270.0030.02517.49
5.5.260.0020.04517.73
5.5.250.0040.04917.53
5.5.240.0180.04017.14
5.5.230.0000.00814.13
5.5.220.0070.00714.35
5.5.210.0040.01114.42
5.5.200.0030.00613.94
5.5.190.0000.01314.38
5.5.180.0000.01414.38
5.5.170.0030.01314.08
5.5.160.0070.00713.91
5.5.150.0120.00314.36
5.5.140.0060.01014.11
5.5.130.0030.01214.07
5.5.120.0030.01014.10
5.5.110.0080.00414.07
5.5.100.0080.00014.10
5.5.90.0060.00614.24
5.5.80.0060.00614.13
5.5.70.0060.00614.23
5.5.60.0040.01214.38
5.5.50.0000.01414.17
5.5.40.0060.00614.27
5.5.30.0070.00714.19
5.5.20.0060.00614.18
5.5.10.0030.00714.34
5.5.00.0030.00813.93
5.4.450.0340.03015.48
5.4.440.0150.02915.24
5.4.430.0440.02815.36
5.4.420.0350.00615.25
5.4.410.0400.00115.16
5.4.400.0350.00315.22
5.4.390.0330.00315.16
5.4.380.0330.00515.17
5.4.370.0320.00215.09
5.4.360.0330.00315.23
5.4.350.0340.00415.06
5.4.340.0040.02211.67
5.4.330.0040.00711.31
5.4.320.0060.02611.78
5.4.310.0070.02811.78
5.4.300.0050.02811.78
5.4.290.0060.02911.78
5.4.280.0060.02211.72
5.4.270.0070.02311.78
5.4.260.0040.02411.79
5.4.250.0090.02011.72
5.4.240.0050.02411.79
5.4.230.0040.02711.72
5.4.220.0070.02411.74
5.4.210.0050.02711.72
5.4.200.0060.02011.73
5.4.190.0040.02611.72
5.4.180.0020.02911.75
5.4.170.0050.02511.72
5.4.160.0050.02811.74
5.4.150.0060.02111.72
5.4.140.0050.02211.56
5.4.130.0050.02011.56
5.4.120.0080.02311.54
5.4.110.0090.02411.56
5.4.100.0110.03211.54
5.4.90.0180.06211.53
5.4.80.0060.02411.62
5.4.70.0040.03611.58
5.4.60.0070.02611.63
5.4.50.0040.03411.58
5.4.40.0080.02711.61
5.4.30.0070.02211.56
5.4.20.0070.02811.63
5.4.10.0080.02611.53
5.4.00.0020.02611.27
5.3.290.0110.05312.80
5.3.280.0110.04412.71
5.3.270.0130.04612.72
5.3.260.0100.03712.72
5.3.250.0040.04012.72
5.3.240.0130.03112.72
5.3.230.0090.04012.71
5.3.220.0030.04512.68
5.3.210.0100.04312.68
5.3.200.0070.05112.68
5.3.190.0070.04812.68
5.3.180.0090.04312.67
5.3.170.0060.04312.67
5.3.160.0100.04012.67
5.3.150.0090.04912.68
5.3.140.0110.03812.66
5.3.130.0060.04812.66
5.3.120.0080.04312.66
5.3.110.0030.04512.66
5.3.100.0070.04312.12
5.3.90.0080.03612.10
5.3.80.0100.04612.09
5.3.70.0070.03812.09
5.3.60.0080.04212.08
5.3.50.0060.05612.02
5.3.40.0090.03712.02
5.3.30.0070.04711.98
5.3.20.0120.04911.77
5.3.10.0090.04411.73
5.3.00.0090.04211.71
5.2.170.0060.0359.21
5.2.160.0040.0329.21
5.2.150.0070.0369.21
5.2.140.0040.0329.21
5.2.130.0030.0319.17
5.2.120.0060.0289.17
5.2.110.0070.0369.18
5.2.100.0080.0379.18
5.2.90.0090.0389.18
5.2.80.0080.0409.17
5.2.70.0040.0439.17
5.2.60.0050.0339.13
5.2.50.0070.0309.09
5.2.40.0030.0339.07
5.2.30.0040.0319.04
5.2.20.0090.0329.04
5.2.10.0070.0288.94
5.2.00.0050.0338.80
5.1.60.0060.0258.09
5.1.50.0060.0268.09
5.1.40.0040.0258.06
5.1.30.0010.0308.41
5.1.20.0070.0248.43
5.1.10.0030.0318.17
5.1.00.0040.0268.17
5.0.50.0040.0236.63
5.0.40.0060.0176.50
5.0.30.0020.0326.31
5.0.20.0030.0196.28
5.0.10.0040.0196.26
5.0.00.0040.0316.26
4.4.90.0040.0144.78
4.4.80.0050.0134.76
4.4.70.0030.0154.75
4.4.60.0010.0174.75
4.4.50.0040.0134.77
4.4.40.0050.0234.71
4.4.30.0000.0184.76
4.4.20.0040.0144.84
4.4.10.0040.0144.84
4.4.00.0040.0244.76
4.3.110.0010.0174.67
4.3.100.0070.0114.66
4.3.90.0040.0144.64
4.3.80.0050.0254.58
4.3.70.0050.0174.63
4.3.60.0030.0164.63
4.3.50.0030.0164.63
4.3.40.0050.0234.54
4.3.30.0050.0193.30
4.3.20.0040.0183.29
4.3.10.0070.0353.25
4.3.00.0000.0236.64

preferences:
40.18 ms | 400 KiB | 5 Q