dallas Thu Sep 4 17:04:03 2003 EDT
Modified files:
/phpdoc/en/reference/pcre/functions preg-replace-callback.xml
Log:
WS fixes.
Index: phpdoc/en/reference/pcre/functions/preg-replace-callback.xml
diff -u phpdoc/en/reference/pcre/functions/preg-replace-callback.xml:1.6
phpdoc/en/reference/pcre/functions/preg-replace-callback.xml:1.7
--- phpdoc/en/reference/pcre/functions/preg-replace-callback.xml:1.6 Mon Jun 16
16:03:02 2003
+++ phpdoc/en/reference/pcre/functions/preg-replace-callback.xml Thu Sep 4
17:04:03 2003
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/pcre.xml, last change in rev 1.47 -->
<refentry id="function.preg-replace-callback">
<refnamediv>
@@ -8,20 +8,20 @@
</refnamediv>
<refsect1>
<title>Description</title>
- <methodsynopsis>
- <type>mixed</type><methodname>preg_replace_callback</methodname>
- <methodparam><type>mixed</type><parameter>pattern</parameter></methodparam>
- <methodparam><type>callback</type><parameter>callback</parameter></methodparam>
- <methodparam><type>mixed</type><parameter>subject</parameter></methodparam>
- <methodparam
choice="opt"><type>int</type><parameter>limit</parameter></methodparam>
- </methodsynopsis>
+ <methodsynopsis>
+ <type>mixed</type><methodname>preg_replace_callback</methodname>
+ <methodparam><type>mixed</type><parameter>pattern</parameter></methodparam>
+ <methodparam><type>callback</type><parameter>callback</parameter></methodparam>
+ <methodparam><type>mixed</type><parameter>subject</parameter></methodparam>
+ <methodparam
choice="opt"><type>int</type><parameter>limit</parameter></methodparam>
+ </methodsynopsis>
<para>
The behavior of this function is almost identical to
<function>preg_replace</function>, except for the fact that instead of
<parameter>replacement</parameter> parameter, one should specify a
<parameter>callback</parameter> that will be called and passed an array of
matched elements in the subject string. The callback should return the
- replacement string.
+ replacement string.
</para>
<example>
<title><function>preg_replace_callback</function> example</title>
@@ -30,9 +30,9 @@
<?php
// this text was used in 2002
// we want to get this up to date for 2003
- $text = "April fools day is 04/01/2002\n";
- $text.= "Last christmas was 12/24/2001\n";
-
+ $text = "April fools day is 04/01/2002\n";
+ $text.= "Last christmas was 12/24/2001\n";
+
// the callback function
function next_year($matches) {
// as usual: $matches[0] is the complete match
@@ -42,7 +42,7 @@
}
echo preg_replace_callback(
- "|(\d{2}/\d{2}/)(\d{4})|",
+ "|(\d{2}/\d{2}/)(\d{4})|",
"next_year",
$text);
@@ -54,13 +54,13 @@
</programlisting>
</example>
<para>
- You'll often need the <parameter>callback</parameter> function
+ You'll often need the <parameter>callback</parameter> function
for a <function>preg_replace_callback</function> in just one place.
In this case you can use <function>create_function</function> to
declare an anonymous function as callback within the call to
<function>preg_replace_callback</function>. By doing it this way
you have all information for the call in one place and do not
- clutter the function namespace with a callback functions name
+ clutter the function namespace with a callback functions name
not used anywhere else.
</para>
<example>
@@ -68,31 +68,31 @@
<programlisting role='php'>
<![CDATA[
<?php
- /* a unix-style command line filter to convert uppercase
+ /* a unix-style command line filter to convert uppercase
* letters at the beginning of paragraphs to lowercase */
- $fp = fopen("php://stdin", "r") or die("can't read stdin");
- while (!feof($fp)) {
- $line = fgets($fp);
- $line = preg_replace_callback(
- '|<p>\s*\w|',
- create_function(
- // single quotes are essential here,
- // or alternative escape all $ as \$
- '$matches',
- 'return strtolower($matches[0]);'
- ),
- $line
- );
- echo $line;
- }
- fclose($fp);
+ $fp = fopen("php://stdin", "r") or die("can't read stdin");
+ while (!feof($fp)) {
+ $line = fgets($fp);
+ $line = preg_replace_callback(
+ '|<p>\s*\w|',
+ create_function(
+ // single quotes are essential here,
+ // or alternative escape all $ as \$
+ '$matches',
+ 'return strtolower($matches[0]);'
+ ),
+ $line
+ );
+ echo $line;
+ }
+ fclose($fp);
?>
]]>
</programlisting>
</example>
<para>
- See also <function>preg_replace</function>,
+ See also <function>preg_replace</function> and
<function>create_function</function>.
</para>
</refsect1>