3v4l.org

run code in 300+ PHP versions simultaneously
<?php $whereClause = ""; $criteria = array("id" => 1, 'tableName' => 'blarg'); foreach($criteria as $key => $value) { switch($key) { case 'tableName': $whereClause .= " WHERE tableName = " . $this->db->qstr($value) . " AND"; break; case 'id': $whereClause .= " WHERE id = " . intval($value) . " AND"; break; case 'translatable': $whereClause .= " WHERE translatable = " . intval($value) . " AND"; break; } } var_dump($whereClause);

preferences:
49.99 ms | 402 KiB | 5 Q