Skip to content
Advertisement

Convert associative array to indexed array with associative subarrays

I have a simple associative array with country data like this:

JavaScript

How can I dynamically transform this array in a multiple array like:

JavaScript

Advertisement

Answer

Simply loop through it and create a new array from each key/value pair.

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