I am trying to divide an array based on values within the array, and to sort it based on keys that the array also has. My array currently looks like this:
array:6 [▼
"player_ids" => array:8 [▼
0 => "103"
1 => "221"
2 => "283"
3 => "321"
4 => "333"
5 => "406"
6 => "425"
7 => "428"
]
"game_id" => array:8 [▼
103 => "33058041"
221 => "33058041"
283 => "33058041"
321 => "33058041"
333 => "33058041"
406 => "33058041"
425 => "33058041"
428 => "33058041"
]
"goals" => array:8 [▼
103 => "0"
221 => "0"
283 => "0"
321 => "0"
333 => "0"
406 => "0"
425 => "0"
428 => "0"
]
"assists" => array:8 [▼
103 => "0"
221 => "0"
283 => "0"
321 => "0"
333 => "0"
406 => "0"
425 => "0"
428 => "0"
]
"yellows" => array:8 [▼
103 => "0"
221 => "0"
283 => "0"
321 => "0"
333 => "0"
406 => "0"
425 => "0"
428 => "0"
]
"red" => array:8 [▼
103 => "0"
221 => "0"
283 => "0"
321 => "0"
333 => "0"
406 => "0"
425 => "0"
428 => "0"
]
]
with arrays with each of the players embedded in a particular field. How would I manipulate this array to make it so that player_ids
would become the first key, like so:
"103" => array:6 [▼
player_ids => "103"
game_id => "33058041"
goals => "0"
assists => "0"
yellows => "0"
red => "0"
]
for each of the player id's listed?