Edit report at https://bugs.php.net/bug.php?id=76827&edit=1
ID: 76827
User updated by: zjz at zjz dot name
Reported by: zjz at zjz dot name
Summary: Introduce a new function struncate or some such
Status: Open
Type: Feature/Change Request
Package: Performance problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Please consider introducing a new function |struncate| or some such to resolve the performance
problem of truncating a very long string to a slightly shorter one.
For example, suppose the user wants to truncate a 50000 byte string to a 49999 byte string(i.e. to
delete the last character), and **the untruncated one is no longer in use**.
Right now the user has to write code as such:
$str = substr($str, 0, -1);
However, this is silly, it is rather bad in performance when the string copying is not necessary as
the untruncated one is no longer in use as mentioned above.
So I'd like to suggest adding a new function |struncate|, which receives two parameters, one is
a reference of a string to be truncated, the other is the truncated length:
function struncate(&$string, $length)
Previous Comments:
------------------------------------------------------------------------
[2018-08-31 08:27:37] zjz at zjz dot name
Description:
------------
Please consider introducing a new function |struncate| or some such to resolve the performance
problem of truncate a very long string to a slightly shorter one.
For example, suppose the user wants to truncate a 50000 byte string to a 49999 byte string(i.e. to
delete the last character), and **the untruncated one is no longer in use**.
Right now the user has to write code as such:
$str = substr($str, 0, -1);
However, this is silly, it is rather bad in performance when the string copying is not necessary as
the untruncated one is no longer in use as mentioned above.
So I'd like to suggest adding a new function |struncate|, which receives two parameters, one is
a reference of a string to be truncated, the other is the truncated length:
function struncate(&$string, $length)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76827&edit=1