note 86339 added to function.str-replace

From: Date: Tue, 14 Oct 2008 01:47:21 +0000
Subject: note 86339 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-145331@lists.php.net to get a copy of this message
While this is a good example: <?php // Order of replacement $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n"; $order = array("\r\n", "\n", "\r"); $replace = '<br />'; // Processes \r\n's first so they aren't converted twice. $newstr = str_replace($order, $replace, $str); ?> It would be more proper to use nl2br(): <?php $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n"; $newstr = nl2br($str); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 76.195.170.186 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/86339 Del: integrated -- https://master.php.net/note/delete/86339/integrated Del: useless -- https://master.php.net/note/delete/86339/useless Del: bad code -- https://master.php.net/note/delete/86339/bad+code Del: spam -- https://master.php.net/note/delete/86339/spam Del: non-english -- https://master.php.net/note/delete/86339/non-english Del: in docs -- https://master.php.net/note/delete/86339/in+docs Del: other reasons-- https://master.php.net/note/delete/86339 Reject -- https://master.php.net/note/reject/86339 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145331) next »