Last active
June 2, 2016 21:18
-
-
Save ardeay/3d6a1388602702bb5fd7e4e8264298b7 to your computer and use it in GitHub Desktop.
Iterate through mixed (string, array, object) POST values gracefully
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 | |
// 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