Skip to content
Advertisement

PHP Array for hard multilevel items

i have this array structure and i want to create other array structure with that:

JavaScript

Each array item have a group of characteristics like:

JavaScript

I need an array that have this values like

Azul=>64GB=>Plastico 128GB=>Cristal

if sub item repeats only write the children value

Azul=>64GB=>Cristal Only adds Cristal because 64GB exists

I have this code in php:

JavaScript

Where $arrCaracteristicas have the long array, and $arrSelectMain have the first level of the array keys:

Code of first level:

JavaScript

This is an image with structure that i want: https://ibb.co/Q8k198Y

If somebody can help me i will invite a beer in paypal 🙂

Advertisement

Answer

This should work, first separate the array into columns and then loop over the items.

JavaScript

Have a look at the sample

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