Skip to content
Advertisement

Transform array, set each array element with parent key php

I am receiving data that is an array of elements that contains an array of tags by language like this

JavaScript

I need to separate each tag by language, so i usearray_map to transform it like this

JavaScript

Bu what i need is the response to be like this

JavaScript

I tried using array_combine, array_walk, and manually doing it inside array_map, but with no success, what could i do?

Advertisement

Answer

Solution with special trick with null as callback of array_map:

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