Hi all,
i am trying to insert data from an xml file into an array only if it is not currently in the array
but its not working as i hoped
here is my code
PHP Code:
foreach($obj->Items->Item as $item)
{
if(isset($item->ItemAttributes->Platform))
{
print $item->ItemAttributes->Platform;
print "<br>";
$platformArray = array();
$x = 0;
if(!in_array($item->ItemAttributes->Platform,$platformArray))
{
# add platform to $platformArray Array
$platformArray[$x] = $item->ItemAttributes->Platform;
$x++;
}
else
{
}
}
}
print_r($platformArray);
print $item->ItemAttributes->Platform; is printing out all the correct info
Code:
PLAYSTATION 3
Xbox 360
PlayStation2
Nintendo Wii
Windows Vista
Sony PSP
Nintendo DS
PLAYSTATION 3
Xbox 360
PLAYSTATION 3
so that part is working ok its just when it comes to adding the data into the array
the output of print_r($platform) is
Code:
Array ( [0] => SimpleXMLElement Object ( [0] => PLAYSTATION 3 ) )
any ideas as to how i can get an array which consists of
Xbox 360
PlayStation2
Nintendo Wii
Windows Vista
Sony PSP
Nintendo DS
PLAYSTATION 3
so that each of the pieces of data appears in the array once.
any ideas please
Luke