我有阵列问题

So, I want to have table with users name, grades and subjects. Table will display only his grades. So I'm generating subject in foreach loop and reading grades depending on his id.

For subject I want to have an array which will contain infos about subject (teacher, classroom, etc.)

For now I have this array:

$subjects = array();
$getSubjects = mysqli_query($con, "SELECT * FROM predmeti");
while ($subject = mysqli_fetch_array($getSubjects)) {
    $subjects[]= array(
        $subject['subject_name'] => array(
            'id' => $subject['id'],
            'name' => $subject['name'],
            'teacher' => $subject['teacher'],
            'short_name' => $subject['short_name'],
            'classroom' => $subject['classroom']
        )
    );

I know this isn't right. I can't get data for each subject.

Could you please help me?

You're accessing the columns by name while mysqli_fetch_array() returns only an integer indexed array. Have you tried mysqli_fetch_assoc()?