Req #43494 [Opn->Sus]: [PATCH] str_trunc - truncate string without break it

From: Date: Tue, 31 Mar 2020 17:16:11 +0000
Subject: Req #43494 [Opn->Sus]: [PATCH] str_trunc - truncate string without break it
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226372@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=43494&edit=1 ID: 43494 Updated by: cmb@php.net Reported by: felipe@php.net Summary: [PATCH] str_trunc - truncate string without break it -Status: Open +Status: Suspended Type: Feature/Change Request Package: Strings related PHP Version: 5.3CVS-2007-12-04 (CVS) Block user comment: N Private report: N New Comment: This certainly would require some discussion – whether the function is wanted at all, and also about details (multibyte support etc.) This bug tracker is not suitable for that kind of discussion, though, so please use the internals@ mailing list[1]. For the time being, I'm suspending this ticket. [1] <https://www.php.net/mailing-lists.php#internals> Previous Comments: ------------------------------------------------------------------------ [2007-12-10 01:24:26] felipe@php.net Renamed, and updated code: http://ecl.zoone.com.br/etc/patches/str_trunc.patch http://ecl.zoone.com.br/etc/patches/str_trunc.phpt ------------------------------------------------------------------------ [2007-12-04 10:22:58] felipe@php.net Description: ------------ As posted in Internals, but not answered... I guess interesting have in PHP one function for truncate string *without break it*, more specifically alphanumeric chars. PS: wordwrap() works different, see the phpt Patch: http://ecl.zoone.com.br/etc/patches/str_truncate.patch phpt: http://ecl.zoone.com.br/etc/patches/str_truncate.phpt --TEST-- str_truncate --FILE-- <?php $str = "Lorem Ipsum is simply dummy text."; var_dump(str_truncate($str, 25, STR_TRUNC_RIGHT)); var_dump(str_truncate($str, 25, STR_TRUNC_LEFT)); var_dump(str_truncate("foo", 1)); var_dump(str_truncate("foo", 1, 1)); ?> --EXPECT-- string(27) "Lorem Ipsum is simply dummy" string(22) "Lorem Ipsum is simply " string(0) "" string(3) "foo" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=43494&edit=1

« previous php.bugs (#226372) next »