如何比较PHP中的XML文件中的两个字符串?

Here is my code: (my PHP version is 5.5.10.)

<?php
# erprate #
$erprate_raw = simplexml_load_file("trafficinfo/ERPRateSet.xml");
$erprate_file = simplexml_load_file("trafficinfo/ERPRateSet.xml")->entry;
$erprate_namespace = $erprate_file->getNameSpaces(true);
# erprate #
        for ($a = 0; $a < ($erprate_file->count()); $a++) {
            $awesome = 1;
            $zoneid = $erprate_raw->entry[$a]->content->children($erprate_namespace['m'])->properties->children($erprate_namespace['d'])->ZoneID;
            if ($a > 0) {
                for ($b = 0; $b < $a; $b++) {
                    // echo $a . " " . $b . '<br>';
                    $zoneidb = $erprate_raw->entry[$b]->content->children($erprate_namespace['m'])->properties->children($erprate_namespace['d'])->ZoneID;
                    if ($zoneid == $zoneidb) {
                        $awesome = 2;
                        break;
                    }
                }
            }
            if ($awesome == 1) {
                echo $zoneid . "<br>";
            }
        }
?>

Here is (an extremely small part of) my XML file: (the original code is 60000+ characters long)

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://datamall.mytransport.sg/LTAoDataService.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">ERPRateSet</title>
  <id>http://datamall.mytransport.sg/ltaodataservice.svc/ERPRateSet</id>
  <updated>2012-02-10T09:25:04Z</updated>
  <link rel="self" title="ERPRateSet" href="ERPRateSet" />
  <entry>
    <id>http://datamall.mytransport.sg/LTAoDataService.svc/ERPRateSet(236026)</id>
    <title type="text">Passenger Cars/Light Goods Vehicles/Taxis</title>
    <summary type="text">VCC Type: Passenger Cars/Light Goods Vehicles/Taxis Zone ID:CT4 Day Type: Weekdays Time: 07:00 - 07:05 Amount: 0.5</summary>
    <updated>2012-02-10T09:25:04Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="ERPRate" href="ERPRateSet(236026)" />
    <category term="LTAModel.ERPRate" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:ERPID m:type="Edm.Int32">236026</d:ERPID>
        <d:VCCType>Passenger Cars/Light Goods Vehicles/Taxis</d:VCCType>
        <d:DayType>Weekdays</d:DayType>
        <d:EffectiveDate m:type="Edm.DateTime">2012-02-06T00:00:00</d:EffectiveDate>
        <d:ZoneID>CT4</d:ZoneID>
        <d:ChargeAmount m:type="Edm.Double">0.5</d:ChargeAmount>
        <d:StartTime>07:00</d:StartTime>
        <d:EndTime>07:03883</d:EndTime>
        <d:Summary>VCC Type: Passenger Cars/Light Goods Vehicles/Taxis Zone ID:CT4 Day Type: Weekdays Time: 07:00 - 07:05 Amount: 0.5</d:Summary>
        <d:CreateDate m:type="Edm.DateTime">2012-02-09T16:34:31.733</d:CreateDate>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://datamall.mytransport.sg/LTAoDataService.svc/ERPRateSet(236027)</id>
    <title type="text">Passenger Cars/Light Goods Vehicles/Taxis</title>
    <summary type="text">VCC Type: Passenger Cars/Light Goods Vehicles/Taxis Zone ID:BKE Day Type: Weekdays Time: 07:00 - 07:30 Amount: 0</summary>
    <updated>2012-02-10T09:25:04Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="ERPRate" href="ERPRateSet(236027)" />
    <category term="LTAModel.ERPRate" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:ERPID m:type="Edm.Int32">236027</d:ERPID>
        <d:VCCType>Passenger Cars/Light Goods Vehicles/Taxis</d:VCCType>
        <d:DayType>Weekdays</d:DayType>
        <d:EffectiveDate m:type="Edm.DateTime">2012-02-06T00:00:00</d:EffectiveDate>
        <d:ZoneID>BKE</d:ZoneID>
        <d:ChargeAmount m:type="Edm.Double">0</d:ChargeAmount>
        <d:StartTime>07:00</d:StartTime>
        <d:EndTime>07:30</d:EndTime>
        <d:Summary>VCC Type: Passenger Cars/Light Goods Vehicles/Taxis Zone ID:BKE Day Type: Weekdays Time: 07:00 - 07:30 Amount: 0</d:Summary>
        <d:CreateDate m:type="Edm.DateTime">2012-02-09T16:34:31.75</d:CreateDate>
      </m:properties>
    </content>
  </entry>
</feed>

It seems that duplicates are somehow still outputted... Can someone help me with this?

try to correct this:

for ($a = 0; $a < ($erprate_file->count()); $a++)

A better option is

for ($a = 0; $a < (count($erprate_file)-1); $a++)

Before, you try to access to an inexistent index to compare