3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $query = "UPDATE `benefits` SET `ins_d`='6' WHERE `ben_id`='1' OR `patient_id`='1' LIMIT 0,1"; $sql_operators_arr = array("SET", "VALUES", "FROM", "WHERE", "LEFT JOIN", "RIGHT JOIN", "INNER JOIN", "OUTER JOIN", "JOIN", "GROUP BY", "ORDER BY", "LIMIT", "AND", "OR"); $vals = ""; foreach ($sql_operators_arr AS $val) { $re = "/(.*?)( )*(" . $val . ")(.*)/"; $subst = "$1\n$2$3$4"; $query = preg_replace($re,$subst,$query); } echo $query;
based on 0HkPl
Output for 5.4.0 - 7.2.0
UPDATE `benefits` SET `ins_d`='6' WHERE `ben_id`='1' OR `patient_id`='1' LIMIT 0,1