Is there a PHP built-in function to unset multiple array items by key?
That would be a native equivalent of:
foreach($badElements as $k) {
unset($allElements[$k]);
}
or, even better:
$keys = array_keys($badElements);
foreach($keys as $k) {
unset($allElements[$k]);
}
You could create an array of the keys you want to remove and loop through, explicitly unsetting them.
Examples:
Or you could point the variable to a new array that has the keys removed.
or pass all of the array members to unset().