Doc #61294 [Opn]: str_replace : array("\n", "\r") isn't working ; array('\n', '\r') is.
| From: | jean-baptiste dot renard at devsuitup dot com | Date: | Mon, 05 Mar 2012 21:59:51 +0000 |
| Subject: | Doc #61294 [Opn]: 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-8026@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
User updated by: jean-baptiste dot renard at devsuitup dot com
Reported by: jean-baptiste dot renard at devsuitup dot com
-Summary: array("\n", "\r") isn't working ;
array('\n', '\r')
is.
+Summary: str_replace : array("\n", "\r") isn't working ;
array('\n', '\r') is.
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows
PHP Version: 5.3.10
Block user comment: N
Private report: N
New Comment:
Summary change : more accurate.
Previous Comments:
------------------------------------------------------------------------
[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