Skip to content

Instantly share code, notes, and snippets.

@ardeay
Last active June 2, 2016 21:18
Show Gist options
  • Save ardeay/3d6a1388602702bb5fd7e4e8264298b7 to your computer and use it in GitHub Desktop.
Save ardeay/3d6a1388602702bb5fd7e4e8264298b7 to your computer and use it in GitHub Desktop.
Iterate through mixed (string, array, object) POST values gracefully
<?php
// clean function to run the array map through
function cleanFunc($input) {
if(is_array($input)){
return array_map("cleanFunc",$input);
} else if(is_object($input)){
return array_map("cleanFunc", (array) $input);
} else {
return $util->cleanInput($input);
}
}
function cleanValue($string){
//run your minipulation here
return $string;
}
// exmaple
// clean post and get variables
$_POST = array_map("cleanFunc",$_POST);
$_GET = array_map("cleanFunc",$_GET);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment