- Document order of replacement (ie. first to last) when search/replace

parameters are arrays. Fixes #38463.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@221791 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dave Barr 2006-10-15 05:06:12 +00:00
parent b78692d6f6
commit 3e2879c046

View file

@ -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 @@ $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 = '<br />';
// Processes \r\n's first so they aren't converted twice.
$newstr = str_replace($order, $replace, $str);
?>
]]>
</programlisting>