|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31544 chunk_split() unexpected result
Submitted: 2005-01-13 18:43 UTC Modified: 2005-01-14 02:19 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: warcraft2002 at libero dot it Assigned:
Status: Not a bug Package: Strings related
PHP Version: Irrelevant OS: Linux
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:
From: warcraft2002 at libero dot it
New email:
PHP Version: OS:


 [2005-01-13 18:43 UTC] warcraft2002 at libero dot it
string chunk_split ( string body [, int chunklen [, string end]])

chunk_split() inserts end to the end of the string too, if the last chunk is long exactly as chunklen.
Following the definition, this is expected:
(quoted from the function page):
"It inserts end (defaults to "\r\n") every chunklen characters"

BUT, this can be unuseful for some procedures. I'm not sure if this behavior was expected by you or if is a bug/mistake.

Reproduce code:
$splitted=chunk_split($string,4," ");
echo $splitted;

Expected result:
echo $splitted returns "0000 1111 " (without the " and WITH the ending space. I expected "0000 1111" (without the ending space and without the " )

Actual result:
Actually I reach my expected result adding:
before echoing...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-14 02:19 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

"1111" counts as 4 (chunklen) characters, this is expected.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 22 12:01:29 2024 UTC