PHP Help Needed (easy q for programmers)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Emil
    Confirmed User
    • Feb 2007
    • 5658

    #1

    PHP Help Needed (easy q for programmers)

    I want to compare 2 strings but it shouldn't matter if the strings are uppercase or lowercase. Can anyone show me what the code would look like?
    Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
    (Signup with ONLY your Email and Password. You can also refer people and get even more.)
  • tnaindex
    Registered User
    • Oct 2008
    • 26

    #2
    if (strtolower($string1)==strtolower($string2))
    {
    Thank_me();
    }

    Comment

    • Babaganoosh
      ♥♥♥ Likes Hugs ♥♥♥
      • Nov 2001
      • 15841

      #3
      http://us.php.net/manual/en/function.strcasecmp.php
      I like pie.

      Comment

      • Emil
        Confirmed User
        • Feb 2007
        • 5658

        #4
        Thanks!!
        Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
        (Signup with ONLY your Email and Password. You can also refer people and get even more.)

        Comment

        • polle54
          Confirmed User
          • Jul 2004
          • 4626

          #5
          Originally posted by tnaindex
          if (strtolower($string1)==strtolower($string2))
          {
          Thank_me();
          }
          That's one way to do it, but there's a string function for it, so if it's a operation that has to repeated many times I think there's less overhead in using:

          Dispite of what you might think is indicated by the name, this function is case insencitive

          Code:
          if(strcasecmp($string1,$string2) == 0)
          {
             Thank_me_more();
          }
          Returns:
          * 0 - if the two strings are equal
          * <0 - if string1 is less than string2
          * >0 - if string1 is greater than string2
          ICQ# 143561781

          Comment

          Working...