php - Replace tabs or multiple spaces -
i wanted check code valid trying (replaces tab(s) or multiple spaces 1 space.
preg_replace('/\t+|\s{2,}/', ' ', $street); however if found tab , space together, wouldn't end 2 spaces then? original space & new 1 tab got replaced with.
how can change spaces in string end being 1 space?
as \s match both tabs , spaces (as other forms of white-space), should trick replace amount of consecutive white-space single space:
preg_replace('/\s+/', ' ', $street);
Comments
Post a Comment