$c = sizeof($question);
for($i =0;$i<$c;++$i){
echo $question[$i].'<br>';
$cc = sizeof($answers[$i]);
for($ii = 1; $ii < $cc; ++$ii){
echo $answers[$i][$ii].'<br>';;
}
}
$c = sizeof($question);
for ($i = 0; $i < $c; ++$i) {
echo $question[$i];
$cc = sizeof($answers[$i]);
for ($ii = 0; $ii < $cc; ++$ii) {
echo $answers[$i][$ii];
}
}
<label>Вопрос №1</label>
<input type="text" name="questions[]">
<label>1 ответ на 1 вопрос</label>
<input type="text" name="answers[1][]">
<label>2 ответ на 1 вопрос</label>
<input type="text" name="answers[1][]">
<label>3 ответ на 1 вопрос</label>
<input type="text" name="answers[1][]">
<label>Вопрос №2</label>
<input type="text" name="questions[]">
<label>1 ответ на 1 вопрос</label>
<input type="text" name="answers[2][]">
<label>2 ответ на 1 вопрос</label>
<input type="text" name="answers[2][]">
$c = sizeof($question);
for($i =0;$i<$c;++$i;){
//перебор вопросов
$cc = sizeof($answers[$i]);
for($i =0;$i<$cc;++$i;){
//перебор ответов
}
}
public static function create($table, $array) //создает строку
{
$questionmarks = array_fill(0,sizeof($array),'?');
$stmt = self::$db->prepare('INSERT INTO `' . $table . '` (' . implode(',', array_keys($array)) . ') VALUES (' . implode(',', $questionmarks) . ')');
$stmt->execute(array_values($array));
}
public static function delete($table, $query, $params = []) //удаляет строку
{
self::$db->prepare('DELETE FROM `' . $table . '` WHERE ' . $query)->execute($params);
}
По-хорошему, в классе User не должно быть никакого доступа к БД. Но до понимания этого тебе ещё лет пять.