What is the easiest and fastest way to get or manipulate the MySQL result with id values as keys in PHP? I know we can simply loop through the entire result set and so on. But what is the fastest and also the simplest way of doing this?
That is to convert,
Array
(
[0] => Array
(
[id] => 1
[user_name] => user1
)
[1] => Array
(
[id] => 3
[user_name] => user3
)
)
to this.
Array
(
[1] => Array
(
[id] => 1
[user_name] => user1
)
[3] => Array
(
[id] => 3
[user_name] => user3
)
)
This question may face some downvotes. But still, i think any answer on this would be helpfull to many.