solvit.io

Remove white spaces for every element contained in a PHP array

Solution
$newArray = array_map('trim', $array);
Example
$array = ['  aaa', 'bbb  ', '  ccc  '];
$newArray = array_map('trim', $array);

// $newArray = ['aaa', 'bbb', 'ccc'];
Find more solutions about: ,