Does anyone know how to do that in the following code, the exercises are shown listed with type numbers like this: 1, 2, 3, 4...?

<?php
$sql = "SELECT * FROM exercises WHERE exercise_id='".$row["exercise_id"]."'";
$result_ej = $conn->query($sql);
$row_ej = $result_ej->fetch_assoc();
?>

<p><?php $row["exercise_id"] ?> <?php echo $row["text"]; ?></p>
<br>

<!--- Radio Button --->

<?php
if ($row["type"] == 0) {

    $ansarray = explode("\n", $row["possible_answers"]);
    $answer = [];
    for($i=0; $i<count($ansarray); $i++) {
        $a = array($i+1, $ansarray[$i]);
        array_push($answer, $a);
    }
    for($i=0; $i<count($answer); $i++) {

        echo "- ".$answer[$i][1]."<br>";
        echo "</div>";
    }

}
?>

This is what I’m getting on my code:

enter image description here

But I would like to have this:

enter image description here

1 Answers

1
justindevs On

echo $i". ".$answer[$i][1]."<br>";