I have nested arrays that do not have keys. I want to add keys in a particular order. What is a clean way to do this?
Start with this array. It is only indexed by position.
[0] => (
[0] => Tyler
[1] => Durden
[2] => 05/07/1985
)
[1] => (
[0] => Edward
[1] => Norton
[2] => 03/21/1988
)
Now apply these keys in order:
['first_name'] =>
['last_name'] =>
['birthday'] =>
Final array:
[0] => (
['first_name'] => Tyler
['last_name'] => Durden
['birthday'] => 05/071985
)
[1] => (
['first_name'] => Edward
['last_name'] => Norton
['birthday'] => 03/21/1988
)
Bonus upvotes if your code allows for any key structure, instead of being hard-coded!