-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.x] Str trim methods #50822
[11.x] Str trim methods #50822
Conversation
8d1286a
to
7acdbfe
Compare
7acdbfe
to
a266fb5
Compare
@patrickomeara why is the white space removed by |
@taylorotwell The whitespace characters are the same, ltrim removes it from the beginning |
Got it. Thanks! |
You might be interested by this documentation: How to trim (or non-breaking space) in PHP? (note it also deals with HTML entities, which is outside the scope of the Laravel methods here). In particular, you may be interested to know that PHP 8.4 will add And a detailed presentation of these upcoming functions: PHP 8.4: Mbstring: New mb_trim, mb_ltrim, and mb_rtrim functions. |
The native methods
trim()
,ltrim()
andrtrim()
don't remove the unicode whitecode characterNBSP
.Str::squish()
removes these characters, as doesTrimStrings
middleware.This PR adds
trim()
,ltrim()
andrtrim()
static methods to theStr
helper, and also uses these methods in the corresponding Stringable calls.Note: For reviewers the whitespace characters don't show up in the web UI.
Test screenshots attached to show them.