在 php 中单击提交按钮后如何获取带有 ID 的名称

How to get this name with id after click submit button in php

现在我想在提交此表单时通过收音机获取此名称和 ID,以将此问题数组上传到数据库。我应该在下面的代码中使用什么:

<form action="forms/handle-questions.php" method="post">
<?php foreach ($questions $key => $question) : ?>
    <div class="row">
        <?= $question['question'] ?>
    </div>
    <div class="form-check ">
         <input class="form-check-input" type="radio" name="radio_<?= $question['id'] ?>" 
                value="good">
         <label class="form-check-label"> good</label>
    </div>
    <div class=" form-check ">
         <input class="form-check-input" type="radio" name="radio_<?= $question['id'] ?>" 
                value="medium">
         <label class="form-check-label" >medium</label>
    </div>
    <div class="form-check ">
         <input class="form-check-input" type="radio" name="radio_<?= $question['id'] ?>"
                value="weak">
         <label class="form-check-label">weak</label>
    </div>
<?php endforeach ?>
<button type="submit" name="handle_questions">Done</button>
</form>

我平时的做法是这样的

在 PHP 表格后 post

foreach($_POST as $key => $val) {
 if (strpos($key, 'radio_') !== false) {
    $question_id = str_replace('radio_','',$key);
    // now you have the question id that this radio value applies to
 }
}