php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40243 Clarify that trim(),ltrim(),rtrim() will trim ANY character in charlist
Submitted: 2007-01-26 01:07 UTC Modified: 2007-02-05 13:50 UTC
From: burg1 at gmx dot net Assigned: bjori (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: burg1 at gmx dot net
New email:
PHP Version: OS:

 

 [2007-01-26 01:07 UTC] burg1 at gmx dot net
Description:
------------
Please clarify what the trim() functions actually do if the charlist argument is present:

ltrim('deeds', 'ed');
returns:
's'

EACH single character in charlist is trimmed from the beginning of the string, REPEATEDLY.

Please include this (or something similar) as a usage example in the docs!

There are already 2 false bug reports filed from people who obviously misunderstood how these functions work:
http://bugs.php.net/bug.php?id=35584
http://bugs.php.net/bug.php?id=22217

To figure this out just gave me an hour-long headache ;-)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-04 13:44 UTC] bjori@php.net
That is why the argument is called "charlist", 
not "wordlist".

If you do however have a rephrase is mind, please share.
 [2007-02-04 14:26 UTC] burg1 at gmx dot net
My first, and foremost, suggestion would be to add another usage example. The three present examples (for ltrim) all deal with whitespace removal. So please include one with character removal, e.g. the "deeds" example given.

Additionally, my second suggestion is to replace the sentence "You can also specify the characters you want to strip, by means of the charlist parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters."
with
"If the carlist parameter is present, each single character given is trimmed from the beginning of the string, repeatedly. With .. you can specify a range of characters."
 [2007-02-05 13:50 UTC] bjori@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Mar 30 21:00:01 2026 UTC