Closed Thread Icon

Topic awaiting preservation: PHP - join two arrays (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=13035" title="Pages that link to Topic awaiting preservation: PHP - join two arrays (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP - join two arrays <span class="small">(Page 1 of 1)</span>\

 
u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 01-15-2004 12:49

What is the easiest way to get this array

code:
Array
(
[ITEM] => Array
(
[0] => 0
[1] => 9
)

[ID] => Array
(
[0] => 1
)

[IMAGE] => Array
(
[0] => 2
[1] => 5
)

[HEIGHT] => Array
(
[0] => 3
)

[WIDTH] => Array
(
[0] => 4
)

[LINK] => Array
(
[0] => 6
[1] => 8
)

[THIS] => Array
(
[0] => 7
)

)



And this array:

code:
Array
(
[0] => Array
(
[tag] => ITEM
[type] => open
[level] => 1
)

[1] => Array
(
[tag] => ID
[type] => complete
[level] => 2
[value] => 3
)

[2] => Array
(
[tag] => IMAGE
[type] => open
[level] => 2
)

[3] => Array
(
[tag] => HEIGHT
[type] => complete
[level] => 3
[value] => 333
)

[4] => Array
(
[tag] => WIDTH
[type] => complete
[level] => 3
[value] => 500
)

[5] => Array
(
[tag] => IMAGE
[type] => close
[level] => 2
)

[6] => Array
(
[tag] => LINK
[type] => open
[level] => 2
)

[7] => Array
(
[tag] => THIS
[type] => complete
[level] => 3
[value] => 2004/01/08
)

[8] => Array
(
[tag] => LINK
[type] => close
[level] => 2
)

[9] => Array
(
[tag] => ITEM
[type] => close
[level] => 1
)

)



Into this:

code:
Array(
[item] => Array
(
[id] => 3
[image] => Array
(
[height] => 333
[width] => 500
)
[link] => Array
(
[this] => 2004/01/08
)
)
)




The first two arrays are the result from the xml_parse_into_struct() function of this xml-file:

<item>
<id>3</id>
<image>
<height>333</height>
<width>500</width>
</image>
<link>
<this>2004/01/08</this>
</link>
</item>


Any hint? I have no idea how to manage this. I thought about recursion, but didn't get it.

Thanks.

edit: or any other way to get the xml-file into the 3rd array?

[This message has been edited by u-neek (edited 01-15-2004).]

u-neek
Bipolar (III) Inmate

From: Berlin, Germany
Insane since: Jan 2001

posted posted 01-15-2004 14:07

Found a parser, that will do it exactly i want: http://www.php.net/xml <- see the post by mreilly at ZEROSPAM dot MAC dot COM

« BackwardsOnwards »

Show Forum Drop Down Menu