Req #75977 [Opn]: Trim internal whitespace from string

From: Date: Sun, 18 Feb 2018 13:22:17 +0000
Subject: Req #75977 [Opn]: Trim internal whitespace from string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214008@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 User updated by: olafvdspek at gmail dot com Reported by: olafvdspek at gmail dot com Summary: Trim internal whitespace from string Status: Open Type: Feature/Change Request Package: Unknown/Other Function PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Readability / teachability maybe. http://php.net/trim got a dedicated function / name as well.. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#214008) next »