-2

I want to make sure that I can get 3 steps from my database. My array should then look like this with 3 foreachs in each other:

user1
   user2
     user6
     user7
user2
   user3
     user7
   user4
     user8
     user9
user3
   user5
     user10
     user11
     user12
Joachim
  • 13
  • 3
  • If you came across this question, knowing nothing about the specific situation, what would your reaction be? Would you have _any_ idea how to answer it? – Patrick Q Oct 24 '19 at 17:20
  • @PatrickQ I want to create something like this: https://stackoverflow.com/questions/18135685/create-multidimensional-array-using-a-foreach-loop but then 3 times. This is 2 times. – Joachim Oct 24 '19 at 17:22

1 Answers1

0

Please, correct me if I'm wrong, but it seems that you want something like this:

foreach ($input as $k1 => $v1) {
    foreach ($v1 as $k2 => $v2) {
        foreach ($v2 as $k3 => $v3) {
            //Do something
        }
    }
}
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175