|
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 GroupAll rights reserved. |
Last updated: Sat Nov 08 14:00:01 2025 UTC |
what's the problem with ``` preg_replace('/\s+/', ' ', $str); ```