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"; } Link to comment https://forums.phpfreaks.com/topic/179379-solved-simple-case-insensitive-question/ 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. Link to comment https://forums.phpfreaks.com/topic/179379-solved-simple-case-insensitive-question/#findComment-946473 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 Link to comment https://forums.phpfreaks.com/topic/179379-solved-simple-case-insensitive-question/#findComment-946482 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. Link to comment https://forums.phpfreaks.com/topic/179379-solved-simple-case-insensitive-question/#findComment-946607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.