Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$data = [
range(1,3),
range(4,6),
range(7,9),
];
$sql = "INSERT INTO testTable (col1,col2,col3) VALUES ";
$values = "(?".str_repeat(",?",count($data[0])-1).")"; // (?,?,?)
$sql . = $values.str_repeat(",$values",count($data)-1);
echo $sql;
$statement = $mysqli->prepare($sql);
$types = str_repeat("s", count($data) * count($data[0]));
$params = array_merge(...$data);
$statement->bind_param($types, ...$params);
$statement->execute();