您正在寻找implode()
查看联机帮助页,它显示了有关使用的信息
call_user_func_array。我编辑了您的一些片段。
function p_statement($mysqli, $query_string = "", $type = "", $vars = []) { $query = $mysqli->prepare($query_string); //assign $type to first index of $vars array_unshift($vars, $type); //Turn all values into reference since call_user_func_array //expects arguments of bind_param to be references //@see mysqli::bind_param() manpage foreach ($vars as $key => $value) { $vars[$key] =& $vars[$key]; } call_user_func_array(array($query, 'bind_param'), $vars); $query->execute(); //INSERT, SELECT, UPDATE and DELETE have each 6 chars, you can //validate it using substr() below for better and faster performance if (strtolower(substr($query_string, 0, 6)) == "select") { $result = $query->get_result(); } else { $result = $query->affected_rows; } $query->close(); return $result;}


