note 62280 added to function.strtolower
| From: | redatiklanumumdotcom at osu1 dot php dot net | Date: | Fri, 24 Feb 2006 02:43:45 +0000 |
| Subject: | note 62280 added to function.strtolower | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104337@lists.php.net to get a copy of this message | ||
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))
----
Server IP: 202.158.56.242
Probable Submitter: 61.5.0.143
----
Manual Page -- http://www.php.net/manual/en/function.strtolower.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+62280
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62280&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+62280&report=yes
Search -- http://master.php.net/manage/user-notes.php