Add function for ensuring all input in an array is strings
This commit is contained in:
		| @@ -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<mixed> $inputs Input array. | ||||
|      * | ||||
|      * @return array<string> | ||||
|      */ | ||||
|     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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user