3v4l.org

run code in 300+ PHP versions simultaneously
<?php $query = "SELECT TABLE FROM FZC WHERE TABLE='chandz' AND TABLE=1 OR DIE='52'"; $strpos_where = strpos($query, 'WHERE') + 6; $strpos_limit = (int) strpos($query, 'LIMIT'); $strpos_group = (int) strpos($query, 'GROUP BY'); $strpos_order = (int) strpos($query, 'ORDER BY'); if($strpos_limit > 0 AND $strpos_limit > $strpos_group AND $strpos_limit > $strpos_order) { $where = substr($query, $strpos_where, $strpos_limit); } elseif($strpos_group > 0 AND $strpos_group > $strpos_limit AND $strpos_group > $strpos_order) { $where = substr($query, $strpos_where, $strpos_group); } elseif($strpos_order > 0 AND $strpos_order > $strpos_limit AND $strpos_order > $strpos_group) { $where = substr($query, $strpos_where, $strpos_order); } else { $where = substr($query, $strpos_where); } $new_query = substr($query, 0, $strpos_where); $where_built = ""; $where_values = array(); $where_break = explode(' AND ', $where); $where_break_c = count($where_break); for($i = 0; $i < $where_break_c; $i++) { if(!isset($where_break[$i])) { continue; } $clausel = $where_break[$i]; if(isset($where_break[$i + 1]) AND preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $where_break[$i + 1]) != 1) { $where_break[$i] = $where_break[$i]." AND ".$where_break[$i + 1]; $clausel = $where_break[$i]; unset($where_break[$i + 1]); } $where_break_or = explode(' OR ', $clausel); $where_break_or_c = count($where_break_or); for($j = 0; $j < $where_break_or_c; $j++) { if(!isset($where_break_or[$i])) { continue; } $clausel2 = $where_break_or[$j]; if(isset($where_break_or[$j + 1]) AND preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $where_break_or[$j + 1]) != 1) { $where_break_or[$j] = $where_break_or[$j]." OR ".$where_break_or[$j + 1]; $clausel2 = $where_break_or[$j]; unset($where_break_or[$j + 1]); } preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $clausel2, $matches); var_dump($matches); } preg_match('/([\`a-z0-9\_\-]+)[\s]{0,1}(\=|LIKE|\<|\>|\<\=|\>\=|!\=)[\s]{0,1}(.*)/i', $clausel, $matches); var_dump($matches); }
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
array(4) { [0]=> string(14) "TABLE='chandz'" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(8) "'chandz'" } array(4) { [0]=> string(14) "TABLE='chandz'" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(8) "'chandz'" } array(4) { [0]=> string(7) "TABLE=1" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(1) "1" } array(4) { [0]=> string(8) "DIE='52'" [1]=> string(3) "DIE" [2]=> string(1) "=" [3]=> string(4) "'52'" } array(4) { [0]=> string(19) "TABLE=1 OR DIE='52'" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(13) "1 OR DIE='52'" }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array(4) { [0]=> string(14) "TABLE='chandz'" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(8) "'chandz'" } array(4) { [0]=> string(14) "TABLE='chandz'" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(8) "'chandz'" } array(4) { [0]=> string(7) "TABLE=1" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(1) "1" } array(4) { [0]=> string(8) "DIE='52'" [1]=> string(3) "DIE" [2]=> string(1) "=" [3]=> string(4) "'52'" } array(4) { [0]=> string(19) "TABLE=1 OR DIE='52'" [1]=> string(5) "TABLE" [2]=> string(1) "=" [3]=> string(13) "1 OR DIE='52'" }

preferences:
230.4 ms | 403 KiB | 330 Q