note 126114 added to function.trim
| From: | mihow at main dot php dot net | Date: | Thu, 27 May 2021 04:02:10 +0000 |
| Subject: | note 126114 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216436@lists.php.net to get a copy of this message | ||
This is the best solution I've found that strips all types of whitespace and it multibyte safe
$new_str = trim(preg_replace("/\s+/u", " ", $str));
Solution taken from here:
https://stackoverflow.com/a/40264711/966058
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 75.164.128.170)
----
Manual Page -- https://php.net/manual/en/function.trim.php
Edit -- https://main.php.net/note/edit/126114
Del: integrated -- https://main.php.net/note/delete/126114/integrated
Del: useless -- https://main.php.net/note/delete/126114/useless
Del: bad code -- https://main.php.net/note/delete/126114/bad+code
Del: spam -- https://main.php.net/note/delete/126114/spam
Del: non-english -- https://main.php.net/note/delete/126114/non-english
Del: in docs -- https://main.php.net/note/delete/126114/in+docs
Del: other reasons-- https://main.php.net/note/delete/126114
Reject -- https://main.php.net/note/reject/126114
Search -- https://main.php.net/manage/user-notes.php