I had to trim all the values from the array. I wrote a loop that traversed through all the values in the array and pushed them to a different (new) array.
Later I came across this function array_map that accepts a callback function and the array – and applies the callback to all individual elements of the array. The loop was replaced by a single line of code which was pretty AWESOME !!!
$my_arr = array_map('trim',$my_arr);