Hi i'm parsing an XML file using PHP to create another XML file in a nicer format which I am eventually going to use to populate an unordered HTML list.
But the XML feed has duplicate entries, and thus my formatted output also has duplicate entries. How can i loop through the feed and remove the duplicates somehow? Using PHP if possible. I'm a bit of a newbie and am not sure what to do with this one.
Here is a typical output (my formatted XML with duplicates):
<films>
<film>
<filmtitle>Death Race 2</filmtitle>
<filmlink>http://www.picturebox.tv/watchnow?id=377029</filmlink>
</film>
<film>
<filmtitle>Death Race 2</filmtitle>
<filmlink>http://www.picturebox.tv/watchnow?id=377029</filmlink>
</film>
<film>
<filmtitle>Shattered Glass</filmtitle>
<filmlink>http://www.picturebox.tv/watchnow?id=UKIC48</filmlink
</film>
<film>
<filmtitle>Shattered Glass</filmtitle>
<filmlink>http://www.picturebox.tv/watchnow?id=UKIC48</filmlink>
</film>
<film>
<filmtitle>The Brothers Bloom</filmtitle>
<filmlink>http://www.picturebox.tv/watchnow?id=380196</filmlink>
</film>
<film>
<filmtitle>The Brothers Bloom</filmtitle>
<filmlink>http://www.picturebox.tv/watchnow?id=380196</filmlink>
</film>
...and so on...
Any help would be great. Thanks.
UPDATE:
I have defined an array before looping through the feed like this:
$filmList = array();
When looping throughout the list I have added entries using:
array_push($filmsForList, array("filmTitle" => $title, "pictureLink" => $pictureLink);
where $filmTitle and $filmLink are the values from the parsed XML. How would I remove duplicates from that? Or stop them entering in the first place?
Thanks...