Jump to content

Archived

This topic is now archived and is closed to further replies.

praveenhotha

String comparison

Recommended Posts

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.

Share this post


Link to post
Share on other sites
strcmp returns 0 when the strings are equal.

Share this post


Link to post
Share on other sites
Use the == operator instead.

[code=php:0]if ($search == $value)[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.