[PHP] Compare Case Insensitive?

2004-04-08 Thread Jeff Oien
How can I compare a variable submitted by a form as case
insensitive? A promotional code will be entered into a form
and it's important that they can enter the code either way.
So if I have
if ($code == 'ABC123') {

I want that to match 'aBC123' 'abc123' or whatever. Thanks.
Jeff
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Compare Case Insensitive?

2004-04-08 Thread Dave Avent
if (strtolower($code) == 'abc123') {

or

if (strtoupper($code) == 'ABC123') {

-Original Message-
From: Jeff Oien [mailto:[EMAIL PROTECTED]
Sent: 08 April 2004 4:21 PM
To: PHP
Subject: [PHP] Compare Case Insensitive?


How can I compare a variable submitted by a form as case
insensitive? A promotional code will be entered into a form
and it's important that they can enter the code either way.
So if I have

if ($code == 'ABC123') {

I want that to match 'aBC123' 'abc123' or whatever. Thanks.
Jeff

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Compare Case Insensitive?

2004-04-08 Thread Richard Harb
let's see:
eregi()
preg_match()
strtolower()
... either one could help you
probably fastest is convert the user string to lower case and compare
... or upper case .. your choice.
Damn. so many options.

Thursday, April 8, 2004, 5:21:15 PM, you wrote:

 How can I compare a variable submitted by a form as case
 insensitive? A promotional code will be entered into a form
 and it's important that they can enter the code either way.
 So if I have

 if ($code == 'ABC123') {

 I want that to match 'aBC123' 'abc123' or whatever. Thanks.
 Jeff

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Compare Case Insensitive?

2004-04-08 Thread Ryan Gibson
You could set your input string to upper case, then make all your
comparisons in upper case

http://www.php.net/manual/en/function.strtoupper.php

On 8/4/04 4:21 pm, Jeff Oien [EMAIL PROTECTED] wrote:

 How can I compare a variable submitted by a form as case
 insensitive? A promotional code will be entered into a form
 and it's important that they can enter the code either way.
 So if I have
 
 if ($code == 'ABC123') {
 
 I want that to match 'aBC123' 'abc123' or whatever. Thanks.
 Jeff

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Compare Case Insensitive?

2004-04-08 Thread John W. Holmes
From: Jeff Oien [EMAIL PROTECTED]

 How can I compare a variable submitted by a form as case
 insensitive? A promotional code will be entered into a form
 and it's important that they can enter the code either way.

strcasecmp(): http://us2.php.net/strcasecmp

or 

strtoupper($string) == 'ABC123'

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php