Hi All,
ok i have been trying to get this to work for ages now with no luck. im trying to pullout pieces of data from an xml url and add specific data into an array. which is working ok ?
i also want to make it so that each array value is unique so that any duplicate entries are not added to the array, this is not working ?
here is my code
[code=php]$platformArray = array();
$x = 0;
foreach($obj->Items->Item as $item)
{
$platform = $item->ItemAttributes->Platform;
if(isset($platform))
{
print “<p>”;
print $platform;
print “<br>”;
print_r($platform);
print “</p>”;
if(!in_array($platform,$platformArray))
{
# add platform to $platformArray Array
$platformArray[] = $platform;
//$x++;
}
}
}
print_r($platformArray);
and here is the output
[CODE]PLAYSTATION 3
SimpleXMLElement Object ( [0] => PLAYSTATION 3 )
Xbox 360
SimpleXMLElement Object ( [0] => Xbox 360 )
PlayStation2
SimpleXMLElement Object ( [0] => PlayStation2 )
Nintendo Wii
SimpleXMLElement Object ( [0] => Nintendo Wii )
Windows Vista
SimpleXMLElement Object ( [0] => Windows Vista )
Sony PSP
SimpleXMLElement Object ( [0] => Sony PSP )
Nintendo DS
SimpleXMLElement Object ( [0] => Nintendo DS )
PLAYSTATION 3
SimpleXMLElement Object ( [0] => PLAYSTATION 3 )
Xbox 360
SimpleXMLElement Object ( [0] => Xbox 360 )
Xbox 360
SimpleXMLElement Object ( [0] => Xbox 360 )
Array ( [0] => SimpleXMLElement Object ( [0] => PLAYSTATION 3 ) [1] => SimpleXMLElement Object ( [0] => Xbox 360 ) [2] => SimpleXMLElement Object ( [0] => PlayStation2 ) [3] => SimpleXMLElement Object ( [0] => Nintendo Wii ) [4] => SimpleXMLElement Object ( [0] => Windows Vista ) [5] => SimpleXMLElement Object ( [0] => Sony PSP ) [6] => SimpleXMLElement Object ( [0] => Nintendo DS ) [7] => SimpleXMLElement Object ( [0] => PLAYSTATION 3 ) [8] => SimpleXMLElement Object ( [0] => Xbox 360 ) [9] => SimpleXMLElement Object ( [0] => Xbox 360 ) )
as you can see when printing out the array im getting:
[9] =>SimpleXMLElement Object ( [0] => Xbox 360 )
insted of
[9] => Xbox 360
can anyone please help me solve this?
here is a snippet for the xml file
[CODE] <ItemSearchResponse>
<OperationRequest>
<RequestId>10444268-ebdd-4e6f-9b8d-8e4917b5aac4</RequestId>
<Arguments>
<Argument Name=”Operation” Value=”ItemSearch” />
<Argument Name=”Service” Value=”AWSECommerceService” />
<Argument Name=”Signature” Value=”” />
<Argument Name=”Version” Value=”2009-03-01″ />
<Argument Name=”Keywords” Value=”Halo” />
<Argument Name=”AWSAccess” />
<Argument Name=”AWSAccessKeyId” Value=”” />
<Argument Name=”Timestamp” Value=”2009-09-15T13:46:47Z” />
<Argument Name=”SearchIndex” Value=”VideoGames” />
</Arguments>
<RequestProcessingTime>0.1190980000000000</RequestProcessingTime>
</OperationRequest>
<Items>
<Request>
<IsValid>True</IsValid>
<ItemSearchRequest>
<Condition>New</Condition>
<DeliveryMethod>Ship</DeliveryMethod>
<Keywords>Halo</Keywords>
<MerchantId>Amazon</MerchantId>
<ResponseGroup>Small</ResponseGroup>
<ReviewSort>-SubmissionDate</ReviewSort>
<SearchIndex>VideoGames</SearchIndex>
</ItemSearchRequest>
</Request>
<TotalResults>151</TotalResults>
<TotalPages>16</TotalPages>
<Item>
<ASIN>B001HWB68K</ASIN>
<DetailPageURL>http://www.amazon.com/Halo-3-ODST-Xb…N%3DB001HWB68K</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Technical Details</Description>
<URL>http://www.amazon.com/Halo-3-ODST-Xb…N%3DB001HWB68K</URL>
</ItemLink>
<ItemLink>
<Description>Add To Baby Registry</Description>
<URL>http://www.amazon.com/gp/registry/ba…N%3DB001HWB68K</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wedding Registry</Description>
<URL>http://www.amazon.com/gp/registry/we…N%3DB001HWB68K</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>http://www.amazon.com/gp/registry/wi…N%3DB001HWB68K</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>http://www.amazon.com/gp/pdp/taf/B00…N%3DB001HWB68K</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>http://www.amazon.com/review/product…N%3DB001HWB68K</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>http://www.amazon.com/gp/offer-listi…N%3DB001HWB68K</URL>
</ItemLink>
</ItemLinks>
<ItemAttributes>
<Manufacturer>Microsoft</Manufacturer>
<ProductGroup>Video Games</ProductGroup>
<Title>Halo 3: ODST</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>B00005NZ1G</ASIN>
<DetailPageURL>http://www.amazon.com/Halo-Combat-Ev…N%3DB00005NZ1G</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Technical Details</Description>
<URL>http://www.amazon.com/Halo-Combat-Ev…N%3DB00005NZ1G</URL>
</ItemLink>
<ItemLink>
<Description>Add To Baby Registry</Description>
<URL>http://www.amazon.com/gp/registry/ba…N%3DB00005NZ1G</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wedding Registry</Description>
<URL>http://www.amazon.com/gp/registry/we…N%3DB00005NZ1G</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>http://www.amazon.com/gp/registry/wi…N%3DB00005NZ1G</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>http://www.amazon.com/gp/pdp/taf/B00…N%3DB00005NZ1G</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>http://www.amazon.com/review/product…N%3DB00005NZ1G</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>http://www.amazon.com/gp/offer-listi…N%3DB00005NZ1G</URL>
</ItemLink>
</ItemLinks>
<ItemAttributes>
<Manufacturer>Microsoft</Manufacturer>
<ProductGroup>Video Games</ProductGroup>
<Title>Halo: Combat Evolved</Title>
</ItemAttributes>
</Item>
<Item>
<ASIN>0345473043</ASIN>
<DetailPageURL>http://www.amazon.com/Books-Flood-Fi…N%3D0345473043</DetailPageURL>
<ItemLinks>
<ItemLink>
<Description>Technical Details</Description>
<URL>http://www.amazon.com/Books-Flood-Fi…N%3D0345473043</URL>
</ItemLink>
<ItemLink>
<Description>Add To Baby Registry</Description>
<URL>http://www.amazon.com/gp/registry/ba…N%3D0345473043</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wedding Registry</Description>
<URL>http://www.amazon.com/gp/registry/we…N%3D0345473043</URL>
</ItemLink>
<ItemLink>
<Description>Add To Wishlist</Description>
<URL>http://www.amazon.com/gp/registry/wi…N%3D0345473043</URL>
</ItemLink>
<ItemLink>
<Description>Tell A Friend</Description>
<URL>http://www.amazon.com/gp/pdp/taf/034…N%3D0345473043</URL>
</ItemLink>
<ItemLink>
<Description>All Customer Reviews</Description>
<URL>http://www.amazon.com/review/product…N%3D0345473043</URL>
</ItemLink>
<ItemLink>
<Description>All Offers</Description>
<URL>http://www.amazon.com/gp/offer-listi…N%3D0345473043</URL>
</ItemLink>
</ItemLinks>
<ItemAttributes>
<Author>Eric Nylund</Author>
<Manufacturer>Del Rey</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>Halo, Books 1-3 (The Flood; First Strike; The Fall of Reach)</Title>
</ItemAttributes>
</Item>
</Items>
</ItemSearchResponse>
many thanks
Luke