Skip to content
Advertisement

PHP rename the keys of an array

How can I rename keys in an array?

Start with this array named $start_array,

JavaScript

and change the keys for ‘date’ and ‘revenue’ so you get this $final_array:

JavaScript

Here is my terrible attempt which works but is messy.

JavaScript

Advertisement

Answer

JavaScript

Try the above code.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement