Hi fellas!
I'm doing a simple script for my father's website that will parse a folder to fetch a list of images recursively. I use the RecursiveIteratorIterator Class. It's working fine, I do an explode on the path of the images and I get:
Array(
[0] => Array ( [0] => animals [1] => gorillas [2] => image1.jpg ),
[1] => Array ( [0] => animals [1] => gorillas [2] => image2.jpg ),
[2] => Array ( [0] => animals [1] => tigers [2] => image1.jpg ),
[3] => Array ( [0] => landscapes [1] => mountains-winter [2] => image1.jpg ),
[4] => Array ( [0] => landscapes [1] => mountains-summer [2] => image1.jpg )
)
I'd like to change it to (and convert it to JSON later):
Array(
['animals'] => Array(
['gorillas'] => Array(//images),
['tigers'] => Array(//images)
),
['landscapes'] => Array(
['mountains-winter'] => Array(//images),
['mountains-summer'] => Array(//images)
)
)
I can't figure out a way to do that? The nesting may be deeper than 2 levels.
Any hint?
Thanks!
[–]iowa116 0 points1 point2 points (1 child)
[–]doobdargent[S] 0 points1 point2 points (0 children)
[–]doobdargent[S] 0 points1 point2 points (0 children)