/**
* Htmlspecialchars wrapper
+ * Support multidimensional array of strings.
*
- * @param string $str the string to escape.
+ * @param mixed $input Data to escape: a single string or an array of strings.
*
* @return string escaped.
*/
-function escape($str)
+function escape($input)
{
- return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false);
+ if (is_array($input)) {
+ $out = array();
+ foreach($input as $key => $value) {
+ $out[$key] = escape($value);
+ }
+ return $out;
+ }
+ return htmlspecialchars($input, ENT_COMPAT, 'UTF-8', false);
}
/**