Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-13-2004, 09:14 AM   #1 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
Case insensitive string comparison

This is probably really simple, but I'm lazy today. Is there a way to compare strings while ignoring case?
Code:
$str1 = 'some text';
$str2 = 'Some Text';

if ($str1 == $str2){ ... }
I want this to evaluate true. I know how to do it with regular expressions, but I was hoping for a quicker way.
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Old 04-13-2004, 10:11 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
PHP Code:
<?
if( strtolower($str1) == strtolower($str2) ) { ...; }
?>
__________________
Mike
sde is offline   Reply With Quote
Old 04-13-2004, 02:01 PM   #3 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
I knew it had to be easy, thanks a bunch!
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Old 04-13-2004, 02:06 PM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
sure np!
__________________
Mike
sde is offline   Reply With Quote
Old 04-13-2004, 04:48 PM   #5 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Hey lazy - strcasecmp()
bdl is offline   Reply With Quote
Old 04-13-2004, 07:24 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
lol, leave it to bdl
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for another program Androto Standard C, C++ 54 10-15-2004 07:21 AM
Upper case string to lower case gamehead200 Standard C, C++ 12 10-15-2004 03:24 AM
From C to Java HighterDK Java 11 07-13-2004 07:15 PM


All times are GMT -8. The time now is 03:51 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting