diff --git a/reference/strings/functions/str-replace.xml b/reference/strings/functions/str-replace.xml index 7804fb7a18..2f2e44d6f4 100644 --- a/reference/strings/functions/str-replace.xml +++ b/reference/strings/functions/str-replace.xml @@ -1,5 +1,5 @@ - + @@ -59,7 +59,11 @@ is an array and replace is a string, then this replacement string is used for every value of search. The converse would not make sense, - though. + though. + + + If search or replace + are arrays, their elements are processed first to last. @@ -84,6 +88,14 @@ $newphrase = str_replace($healthy, $yummy, $phrase); // Use of the count parameter is available as of PHP 5.0.0 $str = str_replace("ll", "", "good golly miss molly!", $count); echo $count; // 2 + +// Order of replacement +$str = "Line 1\nLine 2\rLine 3\r\nLine 4\n"; +$order = array("\r\n", "\n", "\r"); +$replace = '
'; +// Processes \r\n's first so they aren't converted twice. +$newstr = str_replace($order, $replace, $str); + ?> ]]>