php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43524 Carriage Return in implode() truncates output
Submitted: 2007-12-07 00:58 UTC Modified: 2007-12-07 22:40 UTC
From: kris at sledge-hammer dot net Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.5 OS: Mac OS X
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kris at sledge-hammer dot net
New email:
PHP Version: OS:

 

 [2007-12-07 00:58 UTC] kris at sledge-hammer dot net
Description:
------------
Imploding an array on a Carriage Return (\r) produces unexpected result.

Reproduce code:
---------------
$TestArray[] = "Hrm...something is fishy here.";
$TestArray[] = "It seems that newlines work just fine.";
$TestArray[] = "Carriage Returns no so much";

echo "\nNewline:\n";
echo implode("\n",$TestArray);  //works
echo "\nCarriage Return:\n";
echo implode("\r",$TestArray);  //doesn't work

Expected result:
----------------
It should return

Newline:
Hrm...something is fishy here.
It seems that newlines work just fine.
Carriage Returns no so much
Carriage Return:
Hrm...something is fishy here.
It seems that newlines work just fine.
Carriage Returns no so much


Actual result:
--------------
It produces

Newline:
Hrm...something is fishy here.
It seems that newlines work just fine.
Carriage Returns no so much
Carriage Return:
Carriage Returns no so much just fine.


Notice that the CR result looks like buffer issue, returns mashup of two array values.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-07 22:40 UTC] felipe@php.net
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

See http://en.wikipedia.org/wiki/Carriage_return

Example:
print "foo\rb"; // boo
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 06 12:00:01 2025 UTC