Wednesday, 14 August 2013

Filter out certain array keys (and their values), while keeping other array keys and values

Filter out certain array keys (and their values), while keeping other
array keys and values

I'm trying to figure out what, if any, is a function to effectively remove
a certain set of keys for an array.
I tried chaining array_keys and array_diff, but that just seemed to lead
to me getting an array of array keys.
Basically, I want to remove the following keys:
"submit", "form_build_id", "form_token", "form_id", "op",
"multi_reg_checkbox"
While preserving the structure of the original data.
Is array_filter what I am looking for? It sounds like it could be, but it
seems like it is based on value only.

No comments:

Post a Comment