Hi
I have a data set that is coming from a db table like this
science, p1, some text
science, p2, some more text
maths, p1, some text
maths, p2, some more text
All together that are going to be around 200 entries. These are subject descriptions/levels that will be written out into documents for pupils class reports.
I am trying to create an array that looks like this:
$descriptors = [
'science' => [
'p1' => 'text',
'p2' => 'more text'
],
'maths; => [
'p1'=> 'text',
'p2'=> 'more text'.
]
etc
etc
];
At the moment i have an array $subject_list which goes 'Speaking', 'Science', 'Maths' etc
I loop through the $subject_list and perform a query which returns the subject, the grade(the p1 bit) and the text
How do I turn this data in the 2d array shown above. I am trying to put an array with a name into an array but I can't figure it out.
This is as far as I could get
$desc[]=array('subject'=>$sub, 'grade'=>$row['grades'], $row['descriptor']);
but this is creating an array which has about 200 arrays in it - all with 3 items - not what I want
How can I do this please