php trim all array elements
$result = array_map('trim', $source_array);
Source: stackoverflow.com
trim elements of array php
$arr = array( " John ", "Jacob ", " Tom ", " Tim ");
$result = array_map('trim', $arr)
Source: www.tutorialspoint.com