aidan Sun Dec 5 10:12:10 2004 EDT
Modified files:
/phpdoc/en/reference/pcre/functions preg-replace.xml
Log:
Added extra example showing stripping of whitespace (this question is asked
atleast 3 times a day)
http://cvs.php.net/diff.php/phpdoc/en/reference/pcre/functions/preg-replace.xml?r1=1.12&r2=1.13&ty=u
Index: phpdoc/en/reference/pcre/functions/preg-replace.xml
diff -u phpdoc/en/reference/pcre/functions/preg-replace.xml:1.12
phpdoc/en/reference/pcre/functions/preg-replace.xml:1.13
--- phpdoc/en/reference/pcre/functions/preg-replace.xml:1.12 Sat Dec 20
20:05:40 2003
+++ phpdoc/en/reference/pcre/functions/preg-replace.xml Sun Dec 5 10:12:10 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.12 $ -->
+<!-- $Revision: 1.13 $ -->
<!-- splitted from ./en/functions/pcre.xml, last change in rev 1.2 -->
<refentry id="function.preg-replace">
<refnamediv>
@@ -251,6 +251,25 @@
</programlisting>
</example>
</para>
+ <para>
+ <example>
+ <title>Strip whitespace</title>
+ <para>
+ This example strips excess whitespace from a string.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$str = 'foo o';
+$str = preg_replace('/\s\s+/', ' ', $str);
+
+// This will be 'foo o' now
+echo $str;
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
<note>
<para>
Parameter <parameter>limit</parameter> was added after PHP 4.0.1pl2.