|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43494 [PATCH] str_trunc - truncate string without break it
Submitted: 2007-12-04 10:22 UTC Modified: 2011-04-08 21:17 UTC
From: Assigned:
Status: Open Package: Strings related
PHP Version: 5.3CVS-2007-12-04 (CVS) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2007-12-04 10:22 UTC]
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



$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));

string(27) "Lorem Ipsum is simply dummy"
string(22) "Lorem Ipsum is simply "
string(0) ""
string(3) "foo"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-08 21:17 UTC]
-Package: Feature/Change Request +Package: Strings related
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Feb 23 02:01:26 2020 UTC