Req #49007 [Fbk->NoF]: Add limit option to trim functions

From: Date: Sun, 22 Aug 2021 04:22:08 +0000
Subject: Req #49007 [Fbk->NoF]: Add limit option to trim functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235990@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49007&edit=1 ID: 49007 Updated by: php-bugs@lists.php.net Reported by: jason at jasonsw dot com Summary: Add limit option to trim functions -Status: Feedback +Status: No Feedback Type: Feature/Change Request Package: Strings related Operating System: * PHP Version: * Assigned To: cmb Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2021-08-09 15:38:59] cmb@php.net > I wonder what would be a use-case for the $limit parameter. And I still do. Can someone please clarify? ------------------------------------------------------------------------ [2016-12-30 14:33:20] cmb@php.net I wonder what would be a use-case for the $limit parameter. ------------------------------------------------------------------------ [2011-02-26 21:58:06] jthijssen at noxlogic dot nl I've added a patch (both 5.3 and trunk) for adding a "limit" to the [lr]?trim() functions. Using a limit of -1 will trim all (same as without adding the limit) A limit of 0 does nothing (no trimming) A positive limit will only trim the amount of chars as specified ON BOTH SIDES. This means using a limit of 2 in trim() will strip max 2 chars from the left and max 2 chars from the right: trim(" hello ", " ", 2) returns " hello "; ltrim(" hello ", " ", 2) returns " hello "; The only problem to keep it backwards compatible is that you must add the default charlist ( \n\r\t\v\0) in order to use the limit parameter. ------------------------------------------------------------------------ [2009-07-21 17:06:58] jason at jasonsw dot com Description: ------------ It would be great if there was a way to limit the amount of characters that were trimmed from a string, in either ltrim, trim or rtrim, using a new limit parameter. Reproduce code: --------------- --- From manual page: function.ltrim --- ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=49007&edit=1

« previous php.bugs (#235990) next »