Doc #61294 [Opn->Nab]: str_replace : array("\n", "\r") isn't working ; array('\n', '\r') is.
| From: | dtajchreber@php.net | Date: | Thu, 15 Mar 2012 01:14:05 +0000 |
| Subject: | Doc #61294 [Opn->Nab]: str_replace : array("\n", "\r") isn't working ; array('\n', '\r') is. | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-8066@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61294&edit=1
ID: 61294
Updated by: dtajchreber@php.net
Reported by: jean-baptiste dot renard at devsuitup dot com
Summary: str_replace : array("\n", "\r") isn't working ;
array('\n', '\r') is.
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
Manual example works as expected:
http://codepad.org/L2mEjtZv
Perhaps you're viewing the output in a browser and missing something? But there's
no mistake here...
Previous Comments:
------------------------------------------------------------------------
[2012-03-05 21:59:51] jean-baptiste dot renard at devsuitup dot com
Summary change : more accurate.
------------------------------------------------------------------------
[2012-03-05 21:58:24] jean-baptiste dot renard at devsuitup dot com
Description:
------------
---
From manual page: http://www.php.net/function.str-replace
---
In the featured example we have :
$str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
$order = array("\r\n", "\n", "\r");
$replace = '<br />';
// Traitement du premier \r\n, ils ne seront pas convertis deux fois.
$newstr = str_replace($order, $replace, $str);
But I found than using this double quote syntax, \n where being displayed, at least not replaced.
By using simple quotes, this does work (like I was expecting at least :D)
Thanks you for your time guys, PHP rule !
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61294&edit=1