3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Tokenizes text that looks something like SQL. */ function tokenizeSQL( $SQL ) { $functions = array ( 'concat', 'if' ); $token = '\\(|\\)|[\']|"|\140|[*]|,|<|>|<>|=|[+]'; $terminal = $token.'|;| |\\n'; $result = array(); $string = $SQL; $string = ltrim($string); $string = rtrim($string,';').';'; // always ends with a terminal $string = preg_replace( "/[\n\r]/s", ' ', $string ); while( preg_match( "/^($token)($terminal)/s", $string, $matches ) || preg_match( "/^({$token})./s", $string, $matches ) || preg_match( "/^([a-zA-Z0-9_.]+?)($terminal)/s", $string, $matches) ) { $t = $matches[1]; if ($t=='\'') { // it's a string $t = tokSingleQuoteString( $string ); array_push($result, $t); } else if ($t=="\140") { // it's a backtick string (a name) $t = tokBackQuoteString( $string ); array_push($result, $t); } else if ($t=='"') { // it's a double quoted string (a name in normal sql) $t = tokDoubleQuoteString( $string ); array_push($result, $t); } else { array_push($result, $t); } $string = substr( $string, strlen($t) ); $string = ltrim($string); } return $result; } function tokSingleQuoteString( $string ) { // matches a single-quoted string in $string // $string starts with a single quote preg_match('/^(\'.*?\').*$/s', $string, $matches ); return $matches[1]; } function tokBackQuoteString( $string ) { // matches a back-quoted string in $string // $string starts with a back quote preg_match('/^([\140].*?[\140]).*$/s', $string, $matches ); return $matches[1]; } function tokDoubleQuoteString( $string ) { // matches a back-quoted string in $string // $string starts with a back quote preg_match('/^(".*?").*$/s', $string, $matches ); return $matches[1]; } print "<pre>"; print_r(tokenizeSQL('SELECT name, rew from asdf where id in(select papa from sdfff')); print "</pre>";

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.0150.00018.55
8.3.50.0170.01021.27
8.3.40.0090.00618.87
8.3.30.0150.00420.17
8.3.20.0050.00320.38
8.3.10.0060.00322.09
8.3.00.0060.00322.46
8.2.180.0130.01017.00
8.2.170.0120.00922.96
8.2.160.0070.00722.06
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0050.00326.16
8.2.120.0080.00020.94
8.2.110.0000.01119.45
8.2.100.0110.00018.16
8.2.90.0060.00319.22
8.2.80.0050.00319.30
8.2.70.0040.00417.75
8.2.60.0000.00817.90
8.2.50.0000.00818.07
8.2.40.0040.00418.03
8.2.30.0040.00419.55
8.2.20.0030.00617.98
8.2.10.0040.00418.05
8.2.00.0030.00618.01
8.1.280.0120.00325.92
8.1.270.0050.00323.99
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0060.00323.96
8.1.230.0060.00620.89
8.1.220.0040.00418.77
8.1.210.0040.00419.15
8.1.200.0000.00917.60
8.1.190.0000.00817.64
8.1.180.0040.00418.10
8.1.170.0040.00418.90
8.1.160.0040.00419.10
8.1.150.0000.00918.91
8.1.140.0040.00417.71
8.1.130.0000.01017.94
8.1.120.0060.00317.63
8.1.110.0000.00717.61
8.1.100.0080.00017.67
8.1.90.0060.00317.67
8.1.80.0000.00717.63
8.1.70.0000.00717.62
8.1.60.0000.00817.79
8.1.50.0040.00417.61
8.1.40.0030.00717.71
8.1.30.0000.00917.74
8.1.20.0000.00817.84
8.1.10.0000.00817.68
8.1.00.0030.00517.75
8.0.300.0000.00720.10
8.0.290.0040.00417.30
8.0.280.0070.00018.48
8.0.270.0040.00417.29
8.0.260.0070.00317.00
8.0.250.0060.00317.16
8.0.240.0000.01017.03
8.0.230.0070.00017.14
8.0.220.0030.00317.14
8.0.210.0000.00717.02
8.0.200.0000.00617.19
8.0.190.0040.00417.14
8.0.180.0040.00417.14
8.0.170.0040.00416.99
8.0.160.0000.00717.07
8.0.150.0070.00017.02
8.0.140.0030.00617.00
8.0.130.0030.00313.47
8.0.120.0040.00417.04
8.0.110.0050.00317.19
8.0.100.0000.00917.04
8.0.90.0030.00517.20
8.0.80.0000.01517.22
8.0.70.0040.00417.05
8.0.60.0040.00416.98
8.0.50.0020.00517.04
8.0.30.0050.01717.19
8.0.20.0080.01117.46
8.0.10.0040.00417.14
8.0.00.0110.00817.02
7.4.330.0050.00016.87
7.4.320.0080.00016.82
7.4.300.0030.00316.82
7.4.290.0040.00416.91
7.4.280.0000.00816.73
7.4.270.0030.00316.84
7.4.260.0050.00013.61
7.4.250.0080.00016.88
7.4.240.0010.00716.84
7.4.230.0030.00516.95
7.4.220.0090.00916.93
7.4.210.0080.00716.85
7.4.200.0000.00716.93
7.4.190.0070.00016.62
7.4.160.0180.00416.85
7.4.150.0120.00617.40
7.4.140.0070.01017.86
7.4.130.0100.00716.79
7.4.120.0120.00716.76
7.4.110.0170.00416.93
7.4.100.0180.00316.59
7.4.90.0130.00416.80
7.4.80.0120.00919.39
7.4.70.0100.00716.65
7.4.60.0000.02216.83
7.4.50.0060.00316.79
7.4.40.0060.00922.77
7.4.30.0040.01416.68
7.4.00.0060.00915.38
7.3.330.0060.00013.55
7.3.320.0000.00513.53
7.3.310.0040.00316.57
7.3.300.0000.00716.54
7.3.290.0030.01016.58
7.3.280.0060.01016.59
7.3.270.0150.00417.40
7.3.260.0030.01616.61
7.3.250.0060.01116.72
7.3.240.0120.00816.92
7.3.230.0140.00316.88
7.3.210.0060.01216.69
7.3.200.0160.00619.39
7.3.190.0130.00616.63
7.3.180.0100.01316.82
7.3.170.0080.00816.61
7.3.160.0060.01016.82
7.3.120.0080.00614.92
7.3.10.0070.00817.01
7.3.00.0040.01116.93
7.2.330.0070.01016.88
7.2.320.0150.00316.96
7.2.310.0060.01116.92
7.2.300.0140.00416.91
7.2.290.0100.00716.91
7.2.130.0140.00417.06
7.2.120.0060.00617.23
7.2.110.0040.00817.16
7.2.100.0070.00716.98
7.2.90.0060.00817.22
7.2.80.0080.00316.99
7.2.70.0120.00317.16
7.2.60.0050.01017.06
7.2.50.0030.01317.00
7.2.40.0070.00717.10
7.2.30.0030.01217.04
7.2.20.0140.00317.18
7.2.10.0130.00317.10
7.2.00.0000.01217.07
7.1.250.0090.00615.86
7.1.200.0050.01016.03
7.1.70.0060.00917.38
7.1.60.0030.01619.17
7.1.50.0130.00917.22
7.1.00.0100.07022.39
7.0.200.0000.00817.02
7.0.140.0070.07322.00
7.0.100.0130.04719.92
7.0.90.0330.06319.93
7.0.80.0000.05020.15
7.0.70.0130.08019.91
7.0.60.0070.07319.95
7.0.50.0130.07720.28
7.0.40.0030.07320.05
7.0.30.0000.05720.09
7.0.20.0170.06720.19
7.0.10.0170.06720.07
7.0.00.0070.04720.14
5.6.280.0000.07721.07
5.6.250.0100.04020.64
5.6.240.0230.06320.68
5.6.230.0070.07720.64
5.6.220.0030.05020.54
5.6.210.0030.07320.48
5.6.200.0130.06721.04
5.6.190.0070.07321.03
5.6.180.0100.08321.06
5.6.170.0170.07720.98
5.6.160.0100.07721.07
5.6.150.0100.08021.10
5.6.140.0100.08020.96
5.6.130.0030.08021.15
5.6.120.0100.06320.95
5.6.110.0100.05721.08
5.6.100.0130.08021.09
5.6.90.0130.05321.09
5.6.80.0100.03320.36
5.6.70.0130.06720.51
5.6.60.0100.07320.32
5.6.50.0100.08020.48
5.6.40.0100.04720.48
5.6.30.0130.06720.40
5.6.20.0070.07720.40
5.6.10.0100.08320.50
5.6.00.0070.07720.36
5.5.380.0170.05320.43
5.5.370.0030.04320.43
5.5.360.0100.07320.40
5.5.350.0070.08020.38
5.5.340.0100.04720.94
5.5.330.0000.08020.85
5.5.320.0170.06020.75
5.5.310.0170.06020.89
5.5.300.0100.08020.93
5.5.290.0100.08020.66
5.5.280.0130.05020.79
5.5.270.0030.08720.81
5.5.260.0100.04720.87
5.5.250.0170.07320.70
5.5.240.0070.07720.27
5.5.230.0070.05720.32
5.5.220.0100.04320.12
5.5.210.0070.08320.15
5.5.200.0070.07320.30
5.5.190.0130.07720.29
5.5.180.0130.07320.27
5.5.160.0130.07320.16
5.5.150.0130.05320.20
5.5.140.0100.07720.15
5.5.130.0030.06020.00
5.5.120.0100.07720.25
5.5.110.0100.07720.18
5.5.100.0070.05719.99
5.5.90.0070.07720.17
5.5.80.0070.08320.18
5.5.70.0070.05320.07
5.5.60.0070.08019.98
5.5.50.0030.07720.12
5.5.40.0170.04320.17
5.5.30.0130.07320.08
5.5.20.0170.07020.07
5.5.10.0030.04720.13
5.5.00.0130.03719.98
5.4.450.0070.04019.42
5.4.440.0070.08019.28
5.4.430.0070.08019.27
5.4.420.0030.07319.55
5.4.410.0130.07019.32
5.4.400.0000.08719.05
5.4.390.0100.07319.24
5.4.380.0030.08018.90
5.4.370.0130.06719.04
5.4.360.0100.05718.85
5.4.350.0030.07319.21
5.4.340.0070.04019.09
5.4.320.0100.07018.96
5.4.310.0030.04019.04
5.4.300.0100.06719.05
5.4.290.0070.04018.84
5.4.280.0130.07319.13
5.4.270.0030.05318.90
5.4.260.0100.07718.91
5.4.250.0170.06719.09
5.4.240.0130.06019.18
5.4.230.0070.03719.22
5.4.220.0070.06019.15
5.4.210.0170.06319.22
5.4.200.0070.08019.13
5.4.190.0200.06319.22
5.4.180.0100.05019.03
5.4.170.0030.05019.09
5.4.160.0030.08319.20
5.4.150.0070.06319.03
5.4.140.0070.06716.35
5.4.130.0070.06016.46
5.4.120.0100.06316.34
5.4.110.0070.03716.48
5.4.100.0030.04016.58
5.4.90.0030.06716.38
5.4.80.0100.06016.46
5.4.70.0100.05016.51
5.4.60.0170.05716.54
5.4.50.0100.06716.39
5.4.40.0130.07016.27
5.4.30.0070.07016.44
5.4.20.0100.04016.44
5.4.10.0000.07316.50
5.4.00.0170.04015.64
5.3.290.0070.06314.63
5.3.280.0130.03314.68
5.3.270.0070.04314.72
5.3.260.0000.05314.64
5.3.250.0070.07714.63
5.3.240.0000.05314.69
5.3.230.0070.04714.59
5.3.220.0130.07014.57
5.3.210.0130.04714.59
5.3.200.0030.03714.56
5.3.190.0030.07714.59
5.3.180.0100.07014.71
5.3.170.0070.07014.51
5.3.160.0100.07314.55
5.3.150.0070.07714.69
5.3.140.0100.08314.70
5.3.130.0030.08014.62
5.3.120.0100.07714.70
5.3.110.0170.06714.50
5.3.100.0070.07014.01
5.3.90.0100.03313.96
5.3.80.0070.06013.97
5.3.70.0030.05713.93
5.3.60.0030.05314.16
5.3.50.0030.04313.99
5.3.40.0000.07313.95
5.3.30.0000.05313.93
5.3.20.0100.06313.61
5.3.10.0000.03713.78
5.3.00.0070.07013.61
5.2.170.0100.06012.25
5.2.160.0070.06312.25
5.2.150.0000.04712.25
5.2.140.0070.04712.25
5.2.130.0100.06012.25
5.2.120.0130.04312.25
5.2.110.0000.03012.25
5.2.100.0070.03712.25
5.2.90.0030.05712.25
5.2.80.0000.05712.25
5.2.70.0100.03312.25
5.2.60.0100.03012.25
5.2.50.0000.03712.25
5.2.40.0070.04012.25
5.2.30.0070.03012.25
5.2.20.0030.04012.25
5.2.10.0000.06312.25
5.2.00.0030.02712.25
5.1.60.0030.03012.25
5.1.50.0070.03712.25
5.1.40.0030.04312.25
5.1.30.0000.04312.25
5.1.20.0100.03312.25
5.1.10.0070.04312.25
5.1.00.0030.05312.25
5.0.50.0000.05012.25
5.0.40.0000.03012.25
5.0.30.0000.05012.25
5.0.20.0030.03712.25
5.0.10.0030.04012.25
5.0.00.0030.06312.25
4.4.90.0070.01312.25
4.4.80.0070.01712.25
4.4.70.0070.01012.25
4.4.60.0030.02312.25
4.4.50.0000.02012.25
4.4.40.0000.02712.25
4.4.30.0000.03312.25
4.4.20.0030.03712.25
4.4.10.0070.03312.25
4.4.00.0000.05012.25
4.3.110.0000.04012.25
4.3.100.0000.03012.25
4.3.90.0000.04012.25
4.3.80.0030.04012.25
4.3.70.0030.03712.25
4.3.60.0030.03312.25
4.3.50.0030.03712.25
4.3.40.0000.06012.25
4.3.30.0030.03312.25
4.3.20.0000.04012.25
4.3.10.0030.03712.25
4.3.00.0030.03012.25

preferences:
50.65 ms | 400 KiB | 5 Q