i am running a foreach loop to get data from an xml file. the xml file has the same date listed several times, each with different data. what i need to do is show each date only once.
basicly i need the foreach loop to show the first date (object) on the first loop. if the date (object) is the same on the second, third, fourth loop, etc. then skip that loop and move to the next where the date (object) is not the same. here is what i have now:
$dateResults = $xml->xpath('/rtnshowtime/filmtitle/show[preceding-sibling::shortname="AGOODDAYTODIEHARD"]');
foreach ($dateResults as $dateResult) {
print_r($dateResult->date);
echo "<br>";
}
that produces:
SimpleXMLElement Object ( [0] => 02152013 )
SimpleXMLElement Object ( [0] => 02152013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02152013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02162013 )
SimpleXMLElement Object ( [0] => 02162013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02162013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02162013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02162013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02172013 )
SimpleXMLElement Object ( [0] => 02172013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02172013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02172013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02172013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02182013 )
SimpleXMLElement Object ( [0] => 02182013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02192013 )
SimpleXMLElement Object ( [0] => 02192013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02202013 )
SimpleXMLElement Object ( [0] => 02202013 ) <-- this one needs to be skipped
SimpleXMLElement Object ( [0] => 02212013 )
SimpleXMLElement Object ( [0] => 02212013 ) <-- this one needs to be skipped
for separation. the result for the top portion is screen : 6 date : 02152013 time : 1705 Info1 : 0 Info2 : 0 Info3 : 0 Info4 : 0 soldout : 0 reserved : 0 salelink : http://14682.formovietickets.com:2235/Tickets.ASP?WCI=buyticket&Page=PickTickets&Title=AGOODDAYTODIEHARD&ShowTime=20130215170500&Auditorium=6 – JSP254 Feb 16 '13 at 20:38