 <p><a href="http://php.net/manual/en/function.array-map.php"><strong>array_map</strong></a> and <a href="http://php.net/manual/en/function.trim.php"><strong>trim</strong></a> can do the job</p> <pre><code>$trimmed_array=array_map('trim',$fruit); print_r($trimmed_array); </code></pre>