note 62280 deleted from function.strtolower by googleguy

From: Date: Tue, 22 Oct 2013 14:55:38 +0000
Subject: note 62280 deleted from function.strtolower by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197244@lists.php.net to get a copy of this message
Note Submitter: red at iklanumum dot com ---- I've seen this as a common use from script developers, so I would like to share the alternative way to compare 2 string (CASE INSENSITIVE) without using strtolower for faster process. Use strcasecmp() for comparison purpose rather than comparing uncertain case of 2 string variables, because strcasecmp() is approximately 60% faster, moreover, the greater its string length the greater the difference,! Ex. case : $var1; -> could be a mixture of upper & lower case $var2; -> could be a mixture of upper & lower case To compare whether $var1 is exactly the same as $var2 (case insensitive manner): Use -> if (strcasecmp($var1,$var2)==0) rather than -> if (strtolower($var1)==strtolower($var2))

« previous php.notes (#197244) next »