I queried my database and it stores the results into an array. It looks like this:
Array
(
[0] => Array
(
[Submission_ID] => 111
[First_Name] => Dylan
[Last_Name] => Taylor
[Abstract_Title] => Research 1
)
[1] => Array
(
[Submission_ID] => 222
[First_Name] => Michael
[Last_Name] => Jones
[Abstract_Title] => Research 2
)
[2] => Array
(
[Submission_ID] => 333
[First_Name] => Wills
[Last_Name] => Adams
[Abstract_Title] => Research 3
)
)
This is all placed in a variable called $results. Currently, I'm displaying bits of data on my page like so:
echo $results[0][Abstract_Title]
It all works, however, it be convenient if the index keys were replaced with the Submission ID:
Array
(
[111] => Array
(
[Submission_ID] => 111
[First_Name] => Dylan
[Last_Name] => Taylor
[Abstract_Title] => Research 1
)
[222] => Array
(
[Submission_ID] => 222
[First_Name] => Michael
[Last_Name] => Jones
[Abstract_Title] => Research 2
)
[333] => Array
(
[Submission_ID] => 333
[First_Name] => Wills
[Last_Name] => Adams
[Abstract_Title] => Research 3
)
)
So I can do this instead (otherwise I would have to print the array just to look up the index key every time):
echo $results[111][Abstract_Title]
Any ideas? (I'm new to programming.) The closest answer I've found is: php replace array id keys but I can't get my head around the solution. I figured a forloop is the best option? Should the new array be placed in the same variable or new variable?