3v4l.org

run code in 300+ PHP versions simultaneously
<?php // This library is to rewrite MSYQL queries into formatted text class query2text { private $key_arr; public function addline ($query,$keyword) { $fixed = str_ireplace(" ".$keyword,"<br>&nbsp;".$keyword,$query); return $fixed; } public function convert($query) { $key_arr = array("FROM","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","WHERE","AND","OR","ORDER","GROUP"); foreach($key_arr AS $key) { $query = $this->addline($query,$key); } $query .= "<br><br>\n"; return $query; } } $query = "SELECT patients.patient_id,patients.last_name,patients.first_name,appts.*,appt_types.type,appt_types.color,appt_types.bgcolor" . ",DATE_FORMAT(appts.start,'%m/%d/%Y') AS date" . ",DATE_FORMAT(appts.start,'%h:%i %p') AS time" . ",TIMEDIFF(appts.end,appts.start) AS duration" . " FROM patients,appts,appt_types" . " WHERE appts.cancelled IS NULL" . " AND YEAR(appts.start)='2014'" . " AND MONTH(appts.start)='04'" . " AND DAY(appts.start)='1'" . " AND patients.patient_id = appts.patient_id" . " AND appts.type = appt_types.appt_type_id" . " AND (appts.type='4'" . " OR appts.type='5'" . " OR appts.type='6'" . " OR appts.type='7'" . " OR appts.type='8'" . " OR appts.type='9'" . " OR appts.type='10'" . " OR appts.type='11'" . " OR appts.type='12'" . " OR appts.type='13'" . " OR appts.type='15'" . " OR appts.type='16'" . " OR appts.type='17'" . " )" . " ORDER BY appts.start" . " ASC LIMIT 0,6"; $q2t = new query2text(); echo "<hr>" . $q2t->convert($query) . "<hr>\n";

preferences:
36.43 ms | 402 KiB | 5 Q