Multiple functions using array_map

You can define a function to combine these trim and urlencode functions. Then use the new function name or the new function as the first parameter of the array_map() function.

array_map(function($v){
  $v = trim($v);
  $v = urlencode($v);
  return $v
}, $array);

You can do it this way also. Reference: create_function()

Warning: This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.

Try this here code snippet here

$newfunc = create_function('$value', 'return urlencode(trim($value));');
$array=array_map($newfunc, $array);