Hello there!
50 US bucks to the accepted solution for this problem via paypal - only open to users with 100 posts or more so they can confirm receipt on this thread and people can know that I have not created a trick account and rewarded myself LOL.
First reply that works gets the coin, so get cracking 🙂
help needed with traversal of muliti-dimensional array where dimensions are variable - this is a node type affair. Example input array as follows:
Array
(
[310] => Array
(
[297] => Array
(
)
[291] => Array
(
[315] => Array
(
)
[316] => Array
(
)
)
[308] => Array
(
[317] => Array
(
)
[318] => Array
(
)
[319] => Array
(
)
)
[309] => Array
(
)
[298] => Array
(
)
[296] => Array
(
)
)
)
Remember the above is completely variable in regards to dimension!
Required output (based on the above):
Array
(
[0] => Array
(
[id] => 310
[path] => >310>
[positon] => 1
)
[1] => Array
(
[id] => 297
[path] => >310>297>
[positon] => 1
)
[2] => Array
(
[id] => 291
[path] => >310>291>
[positon] => 2
)
[3] => Array
(
[id] => 315
[path] => >310>291>315>
[positon] => 1
)
[4] => Array
(
[id] => 316
[path] => >310>291>316>
[positon] => 2
)
[5] => Array
(
[id] => 308
[path] => >310>308>
[positon] => 3
)
[6] => Array
(
[id] => 317
[path] => >310>308>317>
[positon] => 1
)
[7] => Array
(
[id] => 318
[path] => >310>308>318>
[positon] => 2
)
[8] => Array
(
[id] => 319
[path] => >310>308>319>
[positon] => 3
)
[9] => Array
(
[id] => 309
[path] => >310>300>
[positon] => 4
)
[10] => Array
(
[id] => 298
[path] => >310>298>
[positon] => 5
)
[11] => Array
(
[id] => 296
[path] => >310>296>
[positon] => 6
)
)
The first dimension order is not so important as I will just be looping thru and using the id, path and position.
id - this is the key of each dimension of the array, always unique
path - MUST be in this format - shows the path of parents AND id (look at the input array - see how each parent array key creates this.
position - this shows the position of the array in regards to other siblings in the same parent array - this will be always in the same order as that found in the input array.
Thanks in advance, this has just got me stumped 🙁
-Webvida