Jump to content

[SOLVED] Simple Case insensitive question


sixseven

Recommended Posts

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.

 

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

Link to comment
Share on other sites

Hi sixseven,

 

You could use PHP's array_change_key_case() to do this.

 

Change your code to read:

 

$lcget = array_change_key_case($_GET);
$gallery = $lcget['gallery'];

if($gallery=="arte x arte")
{
   $userImage = "arte_x_arte.jpg";
}

 

The above is useful if you have other $_GET requests you wish to make lowercase, as it will convert the entire $_GET array.

 

Or you could just use PHP's strtolower() function to perform a conversion on the single $_GET using:

 

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

 

Hope this helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.