I have an associative array consist of 4 records. there is 2 input fields called name and grade. i want to add these records inside the associative array like name=>grade. here is what i did but it does not work.
$grades = array("Jim"=>"A+","Pam"=>"B","Kevin"=>"Fail","Oscar"=>"A");
$name = $_POST['name'];
$grade = $_POST['grade'];
$length = count($grades);
for($i=0; $i<$length; $i++){
$grades = array($name => $grade);
}
echo $_POST['name'];

$_POST['name']and$_POST['grade']? What is your expected output? Now you're replacing an array 4 times and echoing something that is not your array.