didou Fri Feb 2 22:44:17 2007 UTC
Modified files:
/phpdoc/en/reference/pcre/functions preg-replace.xml
Log:
Document parameters in the good place
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/pcre/functions/preg-replace.xml?r1=1.21&r2=1.22&diff_format=u
Index: phpdoc/en/reference/pcre/functions/preg-replace.xml
diff -u phpdoc/en/reference/pcre/functions/preg-replace.xml:1.21
phpdoc/en/reference/pcre/functions/preg-replace.xml:1.22
--- phpdoc/en/reference/pcre/functions/preg-replace.xml:1.21 Fri Feb 2
22:11:46 2007
+++ phpdoc/en/reference/pcre/functions/preg-replace.xml Fri Feb 2 22:44:17 2007
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.21 $ -->
+<!-- $Revision: 1.22 $ -->
<refentry id="function.preg-replace">
<refnamediv>
<refname>preg_replace</refname>
@@ -21,43 +21,6 @@
<parameter>pattern</parameter> and replaces them with
<parameter>replacement</parameter>.
</para>
- <para>
- <parameter>Replacement</parameter> may contain references of the form
- <literal>\\<replaceable>n</replaceable></literal> or (since PHP 4.0.4)
- <literal><replaceable>$n</replaceable></literal>, with the latter form
- being the preferred one. Every such reference will be replaced by the text
- captured by the <replaceable>n</replaceable>'th parenthesized pattern.
- <replaceable>n </replaceable>can be from 0 to 99, and
- <literal>\\0</literal> or <literal>$0</literal> refers to the text matched
- by the whole pattern. Opening parentheses are counted from left to right
- (starting from 1) to obtain the number of the capturing subpattern.
- </para>
- <para>
- When working with a replacement pattern where a backreference is immediately
- followed by another number (i.e.: placing a literal number immediately
- after a matched pattern), you cannot use the familiar <literal>\\1</literal>
- notation for your backreference. <literal>\\11</literal>, for example,
- would confuse <function>preg_replace</function> since it does not know
whether
- you want the <literal>\\1</literal> backreference followed by a literal
<literal>1</literal>,
- or the <literal>\\11</literal> backreference followed by nothing. In this
case
- the solution is to use <literal>\${1}1</literal>. This creates an
- isolated <literal>$1</literal> backreference, leaving the
<literal>1</literal>
- as a literal.
- </para>
- <para>
- If <parameter>subject</parameter> is an array, then the search
- and replace is performed on every entry of
- <parameter>subject</parameter>, and the return value is an array
- as well.
- </para>
- <para>
- The <literal>e</literal> modifier makes <function>preg_replace</function>
- treat the <parameter>replacement</parameter> parameter as PHP code after
- the appropriate references substitution is done. Tip: make sure that
- <parameter>replacement</parameter> constitutes a valid PHP code string,
- otherwise PHP will complain about a parse error at the line containing
- <function>preg_replace</function>.
- </para>
</refsect1>
<refsect1 role="parameters">
@@ -71,6 +34,14 @@
The pattern to search for. It can be either a string or an array with
strings.
</para>
+ <para>
+ The <literal>e</literal> modifier makes
<function>preg_replace</function>
+ treat the <parameter>replacement</parameter> parameter as PHP code after
+ the appropriate references substitution is done. Tip: make sure that
+ <parameter>replacement</parameter> constitutes a valid PHP code string,
+ otherwise PHP will complain about a parse error at the line containing
+ <function>preg_replace</function>.
+ </para>
</listitem>
</varlistentry>
<varlistentry>
@@ -87,6 +58,31 @@
array than in the <parameter>pattern</parameter> array, any extra
<parameter>pattern</parameter>s will be replaced by an empty string.
</para>
+ <para>
+ <parameter>replacement</parameter> may contain references of the form
+ <literal>\\<replaceable>n</replaceable></literal> or (since PHP 4.0.4)
+ <literal><replaceable>$n</replaceable></literal>, with the latter form
+ being the preferred one. Every such reference will be replaced by the
text
+ captured by the <replaceable>n</replaceable>'th parenthesized pattern.
+ <replaceable>n </replaceable>can be from 0 to 99, and
+ <literal>\\0</literal> or <literal>$0</literal> refers to the text
matched
+ by the whole pattern. Opening parentheses are counted from left to right
+ (starting from 1) to obtain the number of the capturing subpattern.
+ </para>
+ <para>
+ When working with a replacement pattern where a backreference is
+ immediately followed by another number (i.e.: placing a literal number
+ immediately after a matched pattern), you cannot use the familiar
+ <literal>\\1</literal> notation for your backreference.
+ <literal>\\11</literal>, for example, would confuse
+ <function>preg_replace</function> since it does not know whether you
+ want the <literal>\\1</literal> backreference followed by a literal
+ <literal>1</literal>, or the <literal>\\11</literal> backreference
+ followed by nothing. In this case the solution is to use
+ <literal>\${1}1</literal>. This creates an isolated
+ <literal>$1</literal> backreference, leaving the <literal>1</literal>
+ as a literal.
+ </para>
</listitem>
</varlistentry>
<varlistentry>
@@ -95,6 +91,11 @@
<para>
The string or an array with strings to search and replace.
</para>
+ <para>
+ If <parameter>subject</parameter> is an array, then the search and
+ replace is performed on every entry of <parameter>subject</parameter>,
+ and the return value is an array as well.
+ </para>
</listitem>
</varlistentry>
<varlistentry>