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)
5.4.230.0140.04212.41
5.4.220.0100.04312.41
5.4.210.0110.04012.41
5.4.200.0160.05212.41
5.4.190.0120.04112.40
5.4.180.0120.03912.40
5.4.170.0130.04212.41
5.4.160.0080.04512.41
5.4.150.0100.04312.40
5.4.140.0120.04112.09
5.4.130.0140.04312.07
5.4.120.0120.04412.04
5.4.110.0100.04612.04
5.4.100.0100.04212.04
5.4.90.0120.03912.04
5.4.80.0150.06912.04
5.4.70.0130.03912.03
5.4.60.0130.04112.03
5.4.50.0140.03812.03
5.4.40.0120.03912.02
5.4.30.0120.03912.02
5.4.20.0110.03912.01
5.4.10.0120.03912.01
5.4.00.0200.05011.50
5.3.280.0130.04712.71
5.3.270.0160.04312.72
5.3.260.0130.04512.72
5.3.250.0200.07112.72
5.3.240.0120.04612.72
5.3.230.0180.06712.71
5.3.220.0120.04112.68
5.3.210.0210.04712.68
5.3.200.0130.04112.68
5.3.190.0120.04112.68
5.3.180.0160.03612.67
5.3.170.0120.04312.67
5.3.160.0070.04512.67
5.3.150.0160.05212.67
5.3.140.0110.04112.66
5.3.130.0140.03812.66
5.3.120.0220.06212.65
5.3.110.0120.04312.65
5.3.100.0120.04312.13
5.3.90.0130.03912.11
5.3.80.0120.04212.10
5.3.70.0120.04312.10
5.3.60.0110.04112.08
5.3.50.0120.04712.03
5.3.40.0130.05012.03
5.3.30.0120.04212.00
5.3.20.0180.06611.78
5.3.10.0110.04011.74
5.3.00.0140.04511.72

preferences:
134.28 ms | 1394 KiB | 7 Q