How to trim white spaces of array values in php October 1, 2022 by Tarik array_map and trim can do the job $trimmed_array = array_map('trim', $fruit); print_r($trimmed_array);