I’m working on code that wasn’t written by me. I see that the developer wanted to trim all elements of the array and used array_walk() but what’s the point of declaring a _trim function that all it does is use the standard trim()?
array_walk($arr, '_trim');
function _trim(&$value)
{
$value = trim($value);
}
Yes, for array_walk it would be necessary, because of call-by-reference. In this case it would be in my opinion better to use array_map: