So I need to delete some array elements, is there easy way not including foreach loop?
$privateData = ['id', 'date', 'whatever'];
foreach($privateData as $privateField) {
unset($request[$privateField]);
}
I tried to search array_map array_walk functions for examples but I did not find any.
Here's how you do it using
array_map
:You need to use the
use
option to access$request
from the outer scope.I don't know why you'd want to do it this way. The
foreach
loop is much clearer. But since you asked.