dave Sun Oct 15 05:06:13 2006 UTC
Modified files:
/phpdoc/en/reference/strings/functions str-replace.xml
Log:
- Document order of replacement (ie. first to last) when search/replace
parameters are arrays. Fixes #38463.
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/strings/functions/str-replace.xml?r1=1.19&r2=1.20&diff_format=u
Index: phpdoc/en/reference/strings/functions/str-replace.xml
diff -u phpdoc/en/reference/strings/functions/str-replace.xml:1.19
phpdoc/en/reference/strings/functions/str-replace.xml:1.20
--- phpdoc/en/reference/strings/functions/str-replace.xml:1.19 Fri Aug 11
17:15:27 2006
+++ phpdoc/en/reference/strings/functions/str-replace.xml Sun Oct 15
05:06:12 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.19 $ -->
+<!-- $Revision: 1.20 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry id="function.str-replace">
<refnamediv>
@@ -59,7 +59,11 @@
is an array and <parameter>replace</parameter> is a string, then
this replacement string is used for every value of
<parameter>search</parameter>. The converse would not make sense,
- though.
+ though.
+ </para>
+ <para>
+ If <parameter>search</parameter> or <parameter>replace</parameter>
+ are arrays, their elements are processed first to last.
</para>
<para>
<example>
@@ -84,6 +88,14 @@
// 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 = '<br />';
+// Processes \r\n's first so they aren't converted twice.
+$newstr = str_replace($order, $replace, $str);
+
?>
]]>
</programlisting>