#31544 [Opn->Bgs]: chunk_split() unexpected result
ID: 31544
Updated by: jed@php.net
Reported By: warcraft2002 at libero dot it
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Linux
PHP Version: Irrelevant
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
"1111" counts as 4 (chunklen) characters, this is expected.
Previous Comments:
------------------------------------------------------------------------
[2005-01-13 18:43:21] warcraft2002 at libero dot it
Description:
------------
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:
---------------
$string="00001111";
$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:
$splitted=rtrim($splitted);
before echoing...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31544&edit=1
Thread (2 messages)