Any quicker way to iterate through this kind of nested data?
I’m trying to echo comment values in a hierarchical way as they shown in the pic in HTML list tags. I’ve tried Collection::nest but didn’t work for me.
Any quicker way to iterate through this kind of nested data?
I’m trying to echo comment values in a hierarchical way as they shown in the pic in HTML list tags. I’ve tried Collection::nest but didn’t work for me.
I’d recommend looking into recursive methods (like in a custom View Helper)
Does that mean there aren’t ready CakePHP methods for such a nested object/array data?
Not built in because they heavily depend on what object structure you have.
But there are plugins like https://github.com/dereuromark/cakephp-tools/blob/master/docs/Helper/Tree.md which help you output tree structures
I’ve checked the plugin, but it includes many other helpers along the tree helper which could add up size to the project.
I’ve been trying RecursiveIteratorIterator & RecursiveArrayIterator classes to solve the problem but stuck due to not able to find detailed explanation on those classes.
Many thanks.