Req #75977 [Opn->Sus]: Trim internal whitespace from string
| From: | cmb@php.net | Date: | Mon, 19 Feb 2018 12:08:05 +0000 |
| Subject: | Req #75977 [Opn->Sus]: Trim internal whitespace from string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-214018@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75977&edit=1
ID: 75977
Updated by: cmb@php.net
Reported by: olafvdspek at gmail dot com
Summary: Trim internal whitespace from string
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Unknown/Other Function
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Adding yet another string function to ext/standard is certainly
not uncontroversial (at least I do not see sufficient benefit in
this case) â please, feel free to start the RFC process[1]. I'm
suspending this ticket for the time being.
[1] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2018-02-18 13:22:15] olafvdspek at gmail dot com
Readability / teachability maybe. http://php.net/trim got a
dedicated function / name as well..
------------------------------------------------------------------------
[2018-02-18 09:25:49] jhdxr@php.net
what's the problem with
```
preg_replace('/\s+/', ' ', $str);
```
------------------------------------------------------------------------
[2018-02-18 08:50:23] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75977&edit=1