I'm using an older version of Cake ( 1.3 ).
I have an array which returns the structure of a directory, I have then flattened the array using Set::Flatten() and it outputs the following example;
Array
(
[0] => Screen Shot 2017-10-09 at 7.08.52 pm-1.png
[projects.raiders.0] => Webserver_requests_graph.jpg
[images.0] => Screen Shot 2017-10-09 at 7.08.52 pm.png
[triggers.0] => Screen_Shot_2017-10-09_at_4_52_32_pm.png
[providers.0] => testScreen Shot 2017-10-09 at 7.08.52 pm.png
)
The 'key' represents the file structure, so 0 is /, projects is a directory, the raider is a subdirectory of projects and so on....
I need to create a JSON string which walks through each layer of the above array and put it into the following format;
[ ['fullpathname', 'displaytext', 'isfile'] ]
I also need to add dots to represent the original directory structure, so the above array will turn into the following JSON string;
[
['/', '/', 'false'],
['/Screen Shot 2017-10-09 at 7.08.52 pm-1.png', 'Screen Shot 2017-10-09 at 7.08.52 pm-1.png', 'true'],
['/projects', '.. projects', 'false'],
['/projects/raiders', '.. .. raiders', 'false'],
['/projects/raiders/Webserver_requests_graph.jpg', '.. .. .. Webserver_requests_graph.jpg', 'true'],
['/images', '.. images', 'false'],
['/images/Screen Shot 2017-10-09 at 7.08.52 pm.png', '.. .. Screen Shot 2017-10-09 at 7.08.52 pm.png', 'true'],
['/triggers', '.. triggers', 'false'],
['/triggers/Screen_Shot_2017-10-09_at_4_52_32_pm.png', '.. .. Screen_Shot_2017-10-09_at_4_52_32_pm.png', 'true'],
['/providers', '.. providers', 'false'],
['/providers/testScreen Shot 2017-10-09 at 7.08.52 pm.png', '.. .. testScreen Shot 2017-10-09 at 7.08.52 pm.png', true]
]
I was wondering if I could get some guidance, I'm really really stuck on how to go about this. I have heard about array_walk_recursive, but I dont understand it. any help would be greatly appreciated.
Thank you
.. .. .. Webserver_requests_graph.jpgIsn't it invalid. I think it need to be../../../Webserver_requests_graph.jpgand so on for others5items and the output11, or am I missing something.