I have an array of objects and I wanted to know if there is any way to eliminate the duplicates.
array_unique()
does not detect it.
The solution that works for me is to go through it, take ["tagname"]
from another array, eliminate the duplicates by saving its index and, later, remove the elements with that index from the array of objects.
But this would be giving too many turns to an object that will contain 100k + elements.
Do you know something more optimal?
Thanks!
var_dump in the object array
array(15) {
[0]=>
[...]
[10]=>
object(stdClass)#12 (2) {
["tagname"]=>
string(12) "REPEATED_TAG"
["category"]=>
string(7) "DEFAULT"
}
[11]=>
object(stdClass)#13 (2) {
["tagname"]=>
string(4) "TEST"
["category"]=>
string(7) "DEFAULT"
}
[14]=>
object(stdClass)#16 (2) {
["tagname"]=>
string(12) "REPEATED_TAG"
["category"]=>
string(7) "DEFAULT"
}
[...]
}