Jump to content

Array help - switching around values


Guest

Recommended Posts

I'm doing some work with the Discogs API trying to serialize the data of a release for use in another local application.

 

A release on Discogs is something like a music album, so it contains the tracklisting, artists, remixers etc.

 

Here is a sample track row returned from the API (xml)

 

<track>
<artists>
<artist>
<name>Ramirez</name>
<join>And</join>
</artist>
<artist>
<name>Tajada</name>
</artist>
</artists>
<title>Listen To The Drums</title>
<duration>8:10</duration>
</track>

 

Which more simply looks like this:

Ramirez  And Tajada  -  Listen To The Drums

 

On this, I need to class the artist "Tajada" as a guest on this track, however, the "role" is defined in the previous artist's XML row:

 

<name>Ramirez</name>
<join>And</join>

 

How can I sort through the rows to 'swap' these around?

 

Ideally it would look like this:

 

<track>
<artists>
<artist>
<name>Ramirez</name>
</artist>
<artist>
<name>Tajada</name>
<join>And</join>
</artist>
</artists>
<title>Listen To The Drums</title>
<duration>8:10</duration>
</track>

 

Thanks for any help.

 

Link to comment
https://forums.phpfreaks.com/topic/211251-array-help-switching-around-values/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.