0
I’m doing a check between 2 ids
of 2 different elements in XML
, but when I make the comparison the result is always false
even though the gettype
is the same result and the number is also the same result.
To perform the check I have 2 loops
, one within the other, the first is the result of the comparison of equality:
var_dump($filme->attributes()['id'] == $m->attributes()['id']);
And the second is the comparison of types and id's
:
echo get_class($filme->attributes()['id']) . ' ' .$filme->attributes()['id']
. ' --> ' .
get_class($m->attributes()['id']) . ' ' . $m->attributes()['id'] . '<hr/>';
Below the complete list:
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5718
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5764
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5767
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5792
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5794
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 6015
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 6031
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 6052
Note in the fifth line of the result above that the result is the same but the check is false
bool(false)
SimpleXMLElement 5794 --> SimpleXMLElement 5794
I’ve already checked the types and values and I keep receiving false
.
Would it work that way? could you explain?
– rray
Because the comparison between two objects (Simplexmlelement) can consider other aspects than only the value that is represented... Cast pro string type, comparison is restricted to tag value...
– giordanolima
actually worked. I had tried to use
(int)
but the right one was(integer)
.– RFL