I am facing a problem while storing variable data in array and then array to session. Only for one time the value is stored in array at 0 index, but when the next page loads on next button click to load the next test the value of array is overwritten.
<?php session_start();
$cat_name = $_POST["cat_name"];
$which_test_id = $_POST["which_test_id"];
echo $correct = $_POST["correct"];
$answers[] = array('correct' => $correct);
$_SESSION["results"] = $answers;
print_r($_SESSION["results"]); ?>
[]notation