I have the code below to check if the object is inside the array, but in_array() is always true and I end up with the exact same object inside the array multiple times.
if(!in_array($lang, $lang_array, true)){
$languages .= $lang . ", ";
$lang_array[] = $lang;
}
I end up with something like this:
array(3) {
[0]=> object(SimpleXMLElement)#389 (1) {
["@attributes"]=> array(1) {
["Code"]=> string(1) "E"
}
}
[1]=> object(SimpleXMLElement)#388 (1) {
["@attributes"]=> array(1) {
["Code"]=> string(1) "E"
}
}
[2]=> object(SimpleXMLElement)#387 (1) {
["@attributes"]=> array(1) {
["Code"]=> string(1) "E"
}
}
}
SimpleXMLElementobjects all have different object hashes so they are not the same object.Codeindex on the@attributesproperty of theSimpleXMLElementobject. You would need to loop through each item and check it.