dignick Posted August 23, 2009 Share Posted August 23, 2009 I've just stumbled across a problem that is baffling me. I've got two xml files. Both have the same encoding. I'm using simplexml to read them. All I'm trying to do is an if statement to compare two values from the files. if($flevel->smallname == $level) { $fulllevel=$flevel->name; break; } $level has been set previously from another xml file. This if statement doesn't work. If I echo the two values they equal the same thing. If I test each against what they are set to, it returns true (ie $flevel->smallname=='admin' and $level=='admin'). if I hash the values in the statement it returns true (ie if(md5($flevel->smallname) == md5($level)) ). I can't figure out why these variables are not equal! Here's some code I used to test, and the output. if($flevel->smallname == 'admin') echo 'smallname<br />'; if($level == 'admin') echo 'level<br />'; $lvel = $flevel->smallname; if($level == $lvel) echo 'lvel success!<br />'; if($level == $flevel->smallname) echo 'success!<br />'; if(md5($level) == md5($flevel->smallname)) echo 'md5 success!<br />'; Output: smallname level md5 success! Link to comment https://forums.phpfreaks.com/topic/171528-very-strange-if-statement-problem/ Share on other sites More sharing options...
dignick Posted August 24, 2009 Author Share Posted August 24, 2009 Anyone? Could this be a bug in php? I'm running php 5.2.9. Link to comment https://forums.phpfreaks.com/topic/171528-very-strange-if-statement-problem/#findComment-905016 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.