PHP: How to check if query string or POST vars contain same var twice

Posted by thomasrutter on Stack Overflow See other posts from Stack Overflow or by thomasrutter
Published on 2010-04-09T06:14:21Z Indexed on 2010/04/09 6:23 UTC
Read the original article Hit count: 355

Filed under:
|
|
|

It may sound strange, but in my PHP application I need to check if the same variable name has been declared more than once in the query string or POST variables, and return an error value if this is the case. If my application doesn't return an error in this case, it fails a compliance check.

When accessing vars using $_GET, $_POST, etc, PHP only returns the last value given for each variable name. I can't find a way to tell if any variable appeared more than once.

I simply need to find out if the query string or the variables in the POST body contained the same variable name more than once, whatever the values.

© Stack Overflow or respective owner

Related posts about php

Related posts about query-string