lets say: " i have something here, please allow me! "
will become: "i have something here, please allow me!"
lets say: " i have something here, please allow me! "
will become: "i have something here, please allow me!"
Just use preg_replace (select all spaces (which comes more than one in a row) and replace it with a single space).
Example:
<?php
$str = " i have something here, please allow me! ";
echo trim(preg_replace('/\s{2,}/', ' ', $str));