Skip to content
Advertisement

create a PHP function that works for simple arrays and nested arrays

I am trying to create a function that works on both simple arrays and nested arrays. So far, the function looks like this:

JavaScript

It works fine for simple arrays – for example:

JavaScript

But it fails with the message “Warning: htmlspecialchars() expects parameter 1 to be string, array given…” for nested arrays – for example:

JavaScript

What modifications should be made to the function so it works for both simple arrays and nested arrays?

Advertisement

Answer

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