Skip to content
Advertisement

replace array keys with given respective keys

I have an array like below

JavaScript

I have another array having keys to replace with key information.

JavaScript

I need to replace all keys of array $old with respective values in array $keyReplaceInfo.

Output should be like this

JavaScript

I had to do it manually as below. I am expecting better option. can anyone suggest better way to accomplish this?

JavaScript

I know this can be more simpler.

Advertisement

Answer

JavaScript

I think this looks easier than what you posed.

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