I'm attempting to filter $_POST
data, and later render it as HTML, that is nested arrays, going about three levels deep. My structure looks something like this:
Array
(
[books] ==> Array
(
[book1] ==> Array
(
[0] ==> Title
[1] ==> Author
)
[book2] ==> Array
(
[0] ==> Title
[1] ==> Author
)
)
[articles] ==> Array
(
[article1] ==> Array
(
[0] ==> Journal
[1] ==> Title
)
[article2] ==> Array
(
[0] ==> Journal
[1] ==> Title
)
)
)
I have this gut feeling there's a way to use foreach loops and filter_input_arrays (with array and sanitize arguments), but I'm pretty new to PHP and having a hard go at it. I have successfully filtered other arrays, but I'm wondering if there is a graceful way to iterate through the arrays, filtering them, and returning an object with the same structure.