Skip to content
Advertisement

Sanitize & desanitize multidimensional array

I have the following class I wrote:

JavaScript

The problem is that while it works on strings and one-dimensional arrays, I get the following error with multidimensional arrays:

Warning: htmlspecialchars() expects parameter 1 to be string, array given in C:wampwwwclassesSanitizer.php on line 10

How do I fix this? Any help would be greatly appreciated.

Advertisement

Answer

Your code was not evaluating array in $v Modify your foreach block like this, this modification will sanitize any level of nested array,

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement