<?php function tableName () { return 'table_name'; } function select (array $columns, array $where) { for ($i = 0; $i < count($where); $i++){ $conditions[] = $where[$i][0] . ' ' . $where[$i][1] . ' :' . $where[$i][0]; $params[] = $where[$i][2]; } $sql = implode(" AND ", array_map(fn($cond) => "$cond", $conditions)); $columns = implode(", ",array_map(fn($att) => "$att",$columns)); echo "SELECT $columns FROM ".tableName()." WHERE $sql"; } $arrayCol = ["username","email"]; $arrayWhere = [["id", ">", 3], ["firstname", "=", "John"]]; select($arrayCol,$arrayWhere); ?>
You have javascript disabled. You will not be able to edit any code.