Page 1 of 1

Simple Case insensitive question

Posted: Wed Oct 28, 2009 11:36 am
by sixseven67
I've researched and tried a number of things but can't figure this one out. When this if statement receives 'gallery' from the url I don't want it to be case sensitive. Currently a person would have to type the name exactly as I have it below in order for the correct image to show.

I've tried playing around with the i modifier but it's not coming together. Any help would be great. Thanks.

Code: Select all

 
elseif($_GET['gallery']=="arte x arte")
{
   $userImage = "arte_x_arte.jpg";
}
 

Re: Simple Case insensitive question

Posted: Wed Oct 28, 2009 11:43 am
by Reviresco
Convert gallery and the image names to lower case using strtolower() when you compare them:

http://php.net/manual/en/function.strtolower.php

Re: Simple Case insensitive question

Posted: Wed Oct 28, 2009 12:19 pm
by Mirge
sixseven67 wrote:I've researched and tried a number of things but can't figure this one out. When this if statement receives 'gallery' from the url I don't want it to be case sensitive. Currently a person would have to type the name exactly as I have it below in order for the correct image to show.

I've tried playing around with the i modifier but it's not coming together. Any help would be great. Thanks.

Code: Select all

 
elseif($_GET['gallery']=="arte x arte")
{
   $userImage = "arte_x_arte.jpg";
}
 
In addition to using strtolower(), if you're wanting to replace spaces with underscores, you should also look at http://www.php.net/str_replace/.