When we compare $var==$var2, two variables are compared in case-sensive. When we use 'strpos()' to look for if one variable contains value of another variable, it is case-sensitive too. How could I do both things with case-insensitive?

Thanks.

    Originally posted by TheBB
    The case insensitive "brother" of strpos() is stripos():

    Note that this is in PHP5; if you're still using PHP4.x, the closest would be something like
    strpos(strtolower($search_in), strtolower($search_for));

      Hi,

      since strpos returns 0 if the string was found at the first position in the haystack you can't use e.g.

      if (!strpos(...))

      Use

      if (strpos(...) !== false)

      instead.

      Alternatively you could use preg_match with the modifier i.

      Thomas

        Write a Reply...