You are here: Can't figure out how to create hierarchical multi array in such situation « PHP Programming Language « IT news, forums, messages
Can't figure out how to create hierarchical multi array in such situation

Posted by alexandis on 11/26/07 00:13

I have the following multi array like this:
[0] => [ [0] => "A", [1] => "B", [2] => "C" ]
[1] => [ [0] => "A", [1] => "C", [2] => "D" ]
[2] => [ [0] => "B", [1] => "A", [2] => "B" ]
[3] => [ [0] => "B", [1] => "A", [2] => "D" ]

It should be transformed into this:
["A"] => [
["B"] => [
"C"
],
["C"] => [
"D"
]
],
["B"] => [
["A"] => [
"B", "D"
]
]

- that is to say, i need to split the above structure into classes,
subclasses, subsubclasses and so on, depth is variable...

I thought about recursive function, but can't figure out how it should
look like. Was fighting whole day over this task, but vain... :(

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация