I have two homework problems for school, and i have looked over them several times and didn’t get it
I have this array
Array[10][10][10]
id parent value
1 0 X
2 1 Y
3 1 Z
4 3 A
5 2 B
6 5 C
7 3 D
8 9 E
9 4 F
10 2 G
What i want is to generate a sitemap based on parent column.
Example
1 must be at the root
2 and 3 must be childs of 1
10 and 5 must be childs of 2
... and so on.
I would like if i could generate an .xml like
<object id="1" value="X">
<object id="2" value="Y">
<object id="10" value="G">
</object>
<object id="5" value="B">
</object>
... and so on ...
</object>
</object>
and an array
array(
id = > 1
array
);
i don’t look how it might actually look, maybe something like this
$array = array(
"foo" => "bar",
42 => 24,
"multi" => array(
"dimensional" => array(
"array" => "foo"
)
)
);
and the second problem i will post it later. I’m using PHP for this, but C++ and C# would work as well, because the algorithm is important. Any help would be apreciated, because i’m very curious about this!
I believe your array looks like this
You can try
Output
Function Used