sixseven Posted October 28, 2009 Share Posted October 28, 2009 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"; } Quote Link to comment Share on other sites More sharing options...
Bricktop Posted October 28, 2009 Share Posted October 28, 2009 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. Quote Link to comment Share on other sites More sharing options...
knsito Posted October 28, 2009 Share Posted October 28, 2009 I prefer using the string compare functions. http://us3.php.net/manual/en/function.strcasecmp.php Quote Link to comment Share on other sites More sharing options...
sixseven Posted October 28, 2009 Author Share Posted October 28, 2009 Thanks Bricktop. The strtolower() was exactly what I needed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.