am trying to print out only the unique values. since am receiving a huge object array from the I am trying to use now the ArrayObject class of PHP to iterate
$arrayobject = new ArrayObject($data);
$iterator = $arrayobject->getIterator();
while($iterator->valid()){
echo $iterator->current()->USERID. " : " .$iterator->current()->SUBCATID."<br/>";
$iterator->next();
}
here’s the current result of that
201087 : 1
201146 : 1
201087 : 3
201087 : 2
as you can see, the first data has two other duplicates
and also, the first and second data has similar subcatid..
the objective is, print only the unique userid and subcatid..
how to skip those duplicate data, given that sample code of mine
as a starting point ?
Not quite sure I understand the question but maybe….
You can either sort the array and remember the current userid so your script can skip duplicates until it reaches another id.
or the script remembers all previously processed ids, e.g. in a hashmap/array
both scripts print