GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Help Needed (easy q for programmers) (https://gfy.com/showthread.php?t=880996)

Emil 01-12-2009 08:39 AM

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?

tnaindex 01-12-2009 08:50 AM

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

Babaganoosh 01-12-2009 08:51 AM

http://us.php.net/manual/en/function.strcasecmp.php

Emil 01-12-2009 10:12 AM

Thanks!!

polle54 01-12-2009 10:24 AM

Quote:

Originally Posted by tnaindex (Post 15316236)
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


All times are GMT -7. The time now is 04:08 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123