Skip to content
Advertisement

infinite array loop and combine with other array in loop [PHP]

First, I don’t know is it my question title is correct or not, I’m sorry if I make any confuse.

So I have a set of array which I need to combine on tree method to become any possible new set of array.

here is my array:

JavaScript

what I’m expecting is combining those array value to become new set of array with tree method combination.

JavaScript

As you see above, the combination could be as much as how much array values combined each other.

I can easily combine two array with below code:

JavaScript

But, I have no idea how to combine more than two array as I expected above.

Hopefully you understand what I trying to ask, thank you for your help.

Advertisement

Answer

You can use recursion:

JavaScript

$results will have the desired structure.

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