Skip to content
Advertisement

Display the member of one array depending on the other array

i have an array i and i want to show the array values if the name of same array repeat in the another array and have true value

my arrays like this

JavaScript

i want to showing this all attr selected with true value in like this also I want to sum price of array2 member and array1

JavaScript

i try this but its don`t work properly

JavaScript

Advertisement

Answer

I’d use a combination array_reduce and array_map to transform your data into what you need, then simply loop over that to display your view:

JavaScript

Demo: https://3v4l.org/nS3Gl

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