Q&A > regular expressions > How do I remove whitespace at the beginning or end of my string? - Answer contributed by Mago
Remove whitespace at the beginning and end of your string, as well as consecutive whitespace (more than one whitespace character in a row) throughout the string.
$string = join(' ',split(' ',$string));
|Replies are listed 'Best First'.|
Re: Answer: How do I remove whitespace at the beginning or end of my string?
by Abigail-II (Bishop) on Jul 14, 2003 at 15:05 UTC
Using a regular expression.
by roju (Friar) on Jul 14, 2003 at 17:06 UTC