Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case sensitivity question

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
Is there anyway to be case insensitive on query string?

i.e.

I don't care if it's
?Variable1=blahblahblah
or
?variable1=blahblahblah

And I can't just lowercase the whole line because I do care about the case in blahblahblah.

As is, I'm using
$_GET["Variable1"]

And I know I could do a
$myvar = $_GET["Variable1"];
if (!isset($myvar)) {$myvar = $_GET["variable1"];}

and so on to cover the likely cases, but I'd rather just have something which erases the case sensitivity of it all.

-Rob
 
But there's a way around everything ;)

Guess I'm handparsing the query string.

-Rob
 
If you're putting that much effort into doing something the language wasn't designed for, you have to ask yourself two things:

1) Are you using the right language?
2) Why not just accept what the normal is (ie why bother making it case-insensitive)?
 
Well, the first yes, mostly because in php this is actually an incredibly easy thing to do.

$_SERVER["QUERY_STRING"] holds the string
then I can split it into an associative array, and make all the keys lower case using lcase it is I believe, and now I have a different associative array that works just like $_GET[]

And the second, I may..., but when a page has to receive query strings sent from emails sent by 3 different departments, I'd rather be ready for everything rather than assume they'll format their strings properly.

-Rob
 
just in case anyone else wants this functionality, PHP actually makes it ridiculously easy... and it works with either $_POST or $_GET...

$_GET = array_change_key_case($_GET, CASE_LOWER)

or CASE_UPPER if you prefer

-Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top