Please review the corresponding section of the PHP documentation for array_map(). Note that the function accepts one callback function and any number of arrays following it, making it impossible to place multiple callbacks into a single array_map()
call. If you want to apply multiple functions, you will need to either use nested array_map()
calls or pass an anonymous function. Example:
// Nesting.
array_map('trim', array_map('strtoupper', array(' input1 ', ' Input2')));
// Anonymous function.
array_map(function($elem) {
return trim(strtoupper($elem));
}, array(' input1 ', ' Input2'));
You could also iterate over a list of callbacks like this:
$my_callbacks = array('trim', 'strtoupper');
array_map(function($elem) use ($my_callbacks) {
foreach($my_callbacks as $callback) {
$elem = $callback($elem);
}
return $elem;
}, array(' input1 ', ' Input2'));
There are plenty of ways to approach this problem. You'll need to select the one that best suits your use case.