diff --git a/src/MD_STD_IN.php b/src/MD_STD_IN.php index 355eaa8..8dc23ef 100644 --- a/src/MD_STD_IN.php +++ b/src/MD_STD_IN.php @@ -131,6 +131,27 @@ final class MD_STD_IN { } + /** + * Validates an input array for all entries being strings. Unsets empty values. + * This is especially useful for parsed JSON. + * + * @param array $inputs Input array. + * + * @return array + */ + public static function sanitize_text_array(array $inputs):array { + + $output = []; + + foreach ($inputs as $key => $input) { + if (empty($input)) continue; + $output[$key] = self::sanitize_text($input); + } + + return $output; + + } + /** * Retrieves HTTP input texts from GET or POST variables, whatever is provided. * If neither is given, returns a provided default.