Skip to content

Instantly share code, notes, and snippets.

@yavir-me
Created September 18, 2016 15:39
Show Gist options
  • Save yavir-me/bedeb3817e854c6cd239574501043782 to your computer and use it in GitHub Desktop.
Save yavir-me/bedeb3817e854c6cd239574501043782 to your computer and use it in GitHub Desktop.
Sanitize input data
function cleanInputData(){
$sanitized = array();
foreach($_POST as $cur){
$str = trim($cur);
$str = mb_convert_encoding($str, 'UTF-8', 'UTF-8');
$str = htmlentities($str, ENT_QUOTES, 'UTF-8');
array_push($sanitize, $str);
}
return $sanitized;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment