I've looked through articles and SO questions for the last hour and still can't find exactly what I'm looking for.
I have a single dimensional string array containing containing keys from my multidimensional array. Both arrays are dynamic. I need a way to remove every key in the 1D from the MD array.
It's hard to explain, so let me just show you.
$dynamicKeys = ['date', 'name', 'account'];
$arrayRequiringSanitization = [
'name' => [
'first' => 'Homer',
'last' => 'simpson'
],
'age' => 'unknown',
'facts' => [
'history' => [
'date' => 'whenever',
'occurred' => 'nope'
],
'is' => 'existing'
]
];
function removeDynamicValues($arr, $vals) {
// this is where i need help
}
The removeDynamicValues function should take the $arrayRequiringSanitization and $dynamicKeys and return an array that looks as follows:
$arrayRequiringSanitization = [
'age' => 'unknown',
'facts' => [
'history' => [
'occurred' => 'nope'
],
'is' => 'existing'
]
];
So basically, it removed the name sub array and the date sub sub property. The important part is that both arrays are dynamic, and it's not known how deep $arrayRequiringSanitization will be nested.
Let me know if I need to provide further clarrification.