Array
(
[0] => Array
(
[Aco] => Array
(
[alias] => controllers
)
[children] => Array
(
[0] => Array
(
[Aco] => Array
[alias] => Actions
)
[children] => Array
(
[0] => Array
(
[Aco] => Array
[alias] => admin_index
)
)
[1] => Array
(
[Aco] => Array
(
[alias] => admin_edit
)
)
[2] => Array
(
[Aco] => Array
(
[alias] => admin_inline
)
)
)
)
[1] => Array
(
[Aco] => Array
(
[alias] => Agents
)
[children] => Array
(
[0] => Array
(
[Aco] => Array
(
[alias] => register
)
)
[1] => Array
(
[Aco] => Array
(
[alias] => admin_verify
)
)
[2] => Array
(
[Aco] => Array
(
[alias] => admin_index
)
)
)
)
[2] => Array
(
[Aco] => Array
(
[alias] => Applications
)
[children] => Array
(
[0] => Array
(
[Aco] => Array
(
[alias] => pension
)
)
)
)
[3] => Array
(
[Aco] => Array
(
[alias] => AclManager
)
[children] => Array
(
[0] => Array
(
[Aco] => Array
(
[alias] => Acl
)
[children] => Array
(
[0] => Array
(
[Aco] => Array
(
[alias] => admin_drop
)
)
[1] => Array
(
[Aco] => Array
(
[alias] => admin_drop_perms
)
)
)
)
)
)
)
)
)
Hi
I am not sure if this is directly related to cake. But I think the Hash class could do the job. I have already fiddled around with it, but with no success :(
I would like to transform a multidimensional array to a path syntax in a most simple way. Please look at the example "input array" attached as a txt-file.
The resulting "flat" array should look like this:
Array (
[0] => controllers
[1] => controllers/Actions
[2] => controllers/Actions/admin_index
[3] => controllers/Actions/admin_edit
[4] => controllers/Actions/admin_inline
[5] => controllers/Agents
[6] => controllers/Agents/register
[7] => controllers/Agents/admin_verify
[8] => controllers/Agents/admin_index
[9] => controllers/Applications
[10] => controllers/Applications/pension
[11] => controllers/AclManager
[12] => controllers/AclManager/Acl
[13] => controllers/AclManager/Acl/admin_drop
[14] => controllers/AclManager/Acl/admin_drop_perms
)
The input array could have many "children" - it is not predictable how deep the array actually is.
I am sure this could be achieved with a single line of code, but I don't know how. You?
Thank you very much,
Frank
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Friday, March 22, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment