I have a database with the following information:
| ID | Name | Number |
+----+------+--------+
| 1 | aaa | 1 |
| 2 | bbb | 1 |
| 3 | ccc | 2 |
| 4 | ddd | 2 |
and so on.....
What I want is to make an array like this:
$array[1] = array ('aaa','bbb');
$array[2] = array ('ccc','ddd');
And so on......
How do I achieve that, with a loop?
This is what I got so far:
while ($array = $query_res->fetch_assoc()) {
$final_array[$array['Number']] = array ($array['Name']);
}
print_r($final_array);
This isn't working. I think I should use array_merge but can't figure out how to