Mzor Posted March 28, 2010 Share Posted March 28, 2010 This is something I've never run into before and am having issues with: I have two different simplexml objects that I have data in. I have two pieces of data from them, both of which are: "BC". That's all. I've used strlen to check their length. Now, when I go: $data1->name == "BC" it comes out as true. When I go: $data2->name == "BC" it comes out as true. When I go: $data1->name == $data2->name it comes out false. Whaaat? I simply don't understand why it's doing this. the strings have the same lengths, they both equal the same thing however they don't equal each other? I'm guessing it's because they're from different structures, that's all I can think of... Note that those were examples of the structures I use but it's the same thing. Link to comment https://forums.phpfreaks.com/topic/196745-issues-when-comparing-data-from-different-xml-structures/ Share on other sites More sharing options...
darkfreaks Posted March 28, 2010 Share Posted March 28, 2010 Try this: $data1->name = $data2->name; Link to comment https://forums.phpfreaks.com/topic/196745-issues-when-comparing-data-from-different-xml-structures/#findComment-1032885 Share on other sites More sharing options...
Mzor Posted March 28, 2010 Author Share Posted March 28, 2010 No, the issue here is that I'm doing a comparison. if($data1->name == $data2->name){ //blah blah blah } I should have elaborated on that, but the issue can be shown like this: if($data1->name == "BC"){ //this returns true and this code is executed } if($data2->name == "BC"){ //this ALSO returns true and this code is executed } if($data1->name == $data2->name){ //this code does not happen because even though both pieces of data were shown to be "BC", for some reason the comparison comes out false } I have no idea why it's doing this, but it is... Link to comment https://forums.phpfreaks.com/topic/196745-issues-when-comparing-data-from-different-xml-structures/#findComment-1032919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.