Sunday, September 25, 2011

Array reconstruction

I want to turn the following array into an associative one. The
original array is indexed like [0],[1],[2],…[n]. The function I used
was Set::combine but I couldn't reconstruct all three levels of the
desired associative array.

Array
(
[0] => Array
(
[ACCOUNTS] => Array
(
[description] => A
)

[HEADERS] => Array
(
[description] => B
)

[COLUMNS] => Array
(
[description] => C
[id] => 8
)

)
[1] => Array
(
[ACCOUNTS] => Array
(
[description] => A1
)

[HEADERS] => Array
(
[description] => B1
)

[COLUMNS] => Array
(
[description] => C1
[id] => 9
)

)
)


I want to end up with the following associative array:

Array
(
[A] => Array
(
[B] => Array
(
[C] => 8
)
)
[A1] => Array
(
[B1] => Array
(
[C1] => 9
)
)
)

With the Set::combine function I can create part of the array above
but not the whole array in one go.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: