|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2018-02-18 08:50 UTC] olafvdspek at gmail dot com
 Description:
------------
A function to trim / merge whitespace inside a string (so not just at the begin, end) would be nice to have and especially useful for single-line input.
It should replace all sequences of 1 or more whitespace characters by a single space.
Test script:
---------------
echo trim_all('A  B \t C \n D');
Expected result:
----------------
A B C D
Actual result:
--------------
A  B \t C
 D
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Thu Oct 30 23:00:01 2025 UTC | 
what's the problem with ``` preg_replace('/\s+/', ' ', $str); ```