How can I delete an element from a multi-dimensional array given a key?
I am hoping for this to be greedy so that it deletes all elements in an array that match the keys I pass in. I have this so far where I can traverse a multi-dimensional array but I can't unset the key I need to because I don't have a reference to it!
function traverseArray($array, $keys)
{
foreach($array as $key=>$value)
{
if(is_array($value))
{
traverseArray($value);
} else {
if(in_array($key, $keys))
{
//unset(what goes here?)
}
}
}
}
Call-time pass-by-reference has been deprecated. Especially since I am using this in a class in Code-igniter.