praveenhotha Posted August 17, 2006 Share Posted August 17, 2006 foreach($users as $value) { $key=strcmp($search,$value); if($key==0) { reset($users); print("<br>Welcome click to view my pages"); print("<a href='TestPraveenSession.php'>next page</a>"); } }I am trying to compare 2 strings, using strcmp, so how shud the values be given, it is always giving me false, eventhough i gave the same strings in both the arguments. Link to comment https://forums.phpfreaks.com/topic/17810-string-comparison/ Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 strcmp returns 0 when the strings are equal. Link to comment https://forums.phpfreaks.com/topic/17810-string-comparison/#findComment-76056 Share on other sites More sharing options...
Jeremysr Posted August 17, 2006 Share Posted August 17, 2006 Use the == operator instead.[code=php:0]if ($search == $value)[/code] Link to comment https://forums.phpfreaks.com/topic/17810-string-comparison/#findComment-76057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.