MySQL_Narb Posted February 11, 2013 Share Posted February 11, 2013 FULL source: http://paste2.org/p/2847150 foreach($results as $result){ //skill name $skill = $result->firstChild->nodeValue; $info = $result->getElementsByTagName('td'); //skill info $rank = $info->item(1)->nodeValue; $level = $info->item(2)->nodeValue; $xp = $info->item(3)->nodeValue; if($skill != 'Skill'){ echo '<b>'. $skill .'</b> <b>'. $xp .'</b> <hr>'; if($skill == 'Overall' && $xp == '-'){ $exists = false; break; } //SKILL:RANK:LEVEL:XP $skill_info[] = $skill .':'. $rank .':'. $level .':'. $xp; } } In the above code, why doesn't the following if statement work: if($skill == 'Overall' && $xp == '-'){ $exists = false; break; } As you can see, I echoed out the variables and both are what they should be. I even checked the page source to see if there were any special surprises, and there wasn't. Any ideas? PICTURE OF ECHOED RESULTS: http://puu.sh/20E4q Link to comment https://forums.phpfreaks.com/topic/274317-if-statement-isnt-matching/ Share on other sites More sharing options...
Jessica Posted February 11, 2013 Share Posted February 11, 2013 Do a var_dump on the variables. Link to comment https://forums.phpfreaks.com/topic/274317-if-statement-isnt-matching/#findComment-1411635 Share on other sites More sharing options...
Jessica Posted February 11, 2013 Share Posted February 11, 2013 And also state what you expect it to do to "work" Link to comment https://forums.phpfreaks.com/topic/274317-if-statement-isnt-matching/#findComment-1411636 Share on other sites More sharing options...
MySQL_Narb Posted February 11, 2013 Author Share Posted February 11, 2013 Do a var_dump on the variables. Aha, thank you. Forgot about this. It turns out the string had extra whitespaces in it. Thanks. Link to comment https://forums.phpfreaks.com/topic/274317-if-statement-isnt-matching/#findComment-1411652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.