I made this function to check for expected request variables. It was working great until I realized that if two values (Not keys) were the same, it would return a positive number as though a key was missing. Consider the following code:
function requestCheck($expectedAr)
{
if(isset($_GET) && isset($_POST))
{
$requestAr = array_unique(array_merge($_GET, $_POST));
}elseif(isset($_GET)){
$requestAr = $_GET;
}elseif(isset($_POST)){
$requestAr = $_POST;
}else{
$requestAr = array();
}
$diffAr = array_diff_key(array_flip($expectedAr),$requestAr);
if(count($diffAr) > 0)
{
returnError("Missing variables: ".implode(',',array_flip($diffAr)).".");
}else {
return $requestAr;
}
}
$requestAr = requestCheck(['name','password']);
if 'name' and 'password' both hold the same value, it will run returnError(). Not seeing why.
Here's a dump of $_POST:
array (
'poolName' => 'xpool',
'userPrefix' => 'xpool'
)
var_exportto dump them?