foreach ($var as $index => &$value) { if ($value == "") { echo "ERROR, INDEX #{$index} is empty"; die(); } $value = htmlspecialchars(stripcslashes(addslashes(strip_tags(trim($value))))); return $var; }