Created
December 15, 2011 02:07
-
-
Save davidrenne/1479507 to your computer and use it in GitHub Desktop.
Seriously Is It this much code to support case insensitive post/get keys? There has got to be a better way...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$caseInsensitivePosts = array('your_desired_cleaned_lower_case_post_var'); | |
foreach($_GET as $k=>$v) | |
{ | |
$lower = strtolower($k); | |
foreach ($caseInsensitivePosts as $requestVal) | |
{ | |
if ($requestVal == $lower && $k !== $requestVal) | |
{ | |
//clean keys to lowercase for calling pages to handle consistent values | |
$_GET[$lower] = $_GET[$k]; | |
$_REQUEST[$lower] = $_GET[$k]; | |
if (array_key_exists($k,$_GET)) | |
{ | |
unset($_GET[$k]); | |
} | |
if (array_key_exists($k,$_REQUEST)) | |
{ | |
unset($_REQUEST[$k]); | |
} | |
} | |
} | |
} | |
foreach($_POST as $k=>$v) | |
{ | |
$lower = strtolower($k); | |
foreach ($caseInsensitivePosts as $requestVal) | |
{ | |
if ($requestVal == $lower && $k !== $requestVal) | |
{ | |
//clean keys to lowercase for calling pages to handle consistent values | |
$_POST[$lower] = $_POST[$k]; | |
$_REQUEST[$lower] = $_POST[$k]; | |
if (array_key_exists($k,$_POST)) | |
{ | |
unset($_POST[$k]); | |
} | |
if (array_key_exists($k,$_REQUEST)) | |
{ | |
unset($_REQUEST[$k]); | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment