I have a xml file with Shows and Seasons in it.
What i'm trying to do is to read out the seasons for one show. But the problem is that each seasons is represented multiple times under the same show.
I only want each season number printed out one time like:
Season 1
Season 2
But what i got now is:
Season 1
Season 2
Season 2
Season 1
Season 1
My xml looks like
<?xml version="1.0"?>
<episodeview>
<episodeview>
<idShow>1</idShow>
<idSeason>1</idSeason>
</episodeview>
<episodeview>
<idShow>1</idShow>
<idSeason>2</idSeason>
</episodeview>
<episodeview>
<idShow>1</idShow>
<idSeason>2</idSeason>
</episodeview>
<episodeview>
<idShow>1</idShow>
<idSeason>1</idSeason>
</episodeview>
<episodeview>
<idShow>1</idShow>
<idSeason>1</idSeason>
</episodeview>
</episodeview>
And my php file:
<?php
$idShow = "1";
$source = "show.xml";
$xmlstr = file_get_contents($source);
$xmlcont = new SimpleXMLElement($xmlstr);
foreach($xmlcont as $url) {
if ($url->idShow == $idShow) {
$test = $url->idSeason;
echo "Season ";
echo $test;
echo "<br>";
}
}
?>