cvs: /phpdoc/functions strings.sgml
| From: | Torben Wilson | Date: | Mon, 22 Nov 1999 10:53:30 +0000 |
| Subject: | cvs: /phpdoc/functions strings.sgml | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-12914@lists.php.net to get a copy of this message | ||
cslawi Mon Nov 22 05:53:30 1999 EDT
Modified files:
/phpdoc/functions strings.sgml
Log:
Documented substr_replace().
Index: phpdoc/functions/strings.sgml
diff -u phpdoc/functions/strings.sgml:1.25 phpdoc/functions/strings.sgml:1.26
--- phpdoc/functions/strings.sgml:1.25 Mon Nov 15 19:41:55 1999
+++ phpdoc/functions/strings.sgml Mon Nov 22 05:53:29 1999
@@ -1876,6 +1876,88 @@
</refsect1>
</refentry>
+
+ <refentry id="substr-replace">
+ <refnamediv>
+ <refname>substr_replace</refname>
+ <refpurpose>Replace text within a portion of a string.</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcdef>string <function>substr_replace</function></funcdef>
+ <paramdef>string <parameter>string</parameter></paramdef>
+ <paramdef>string <parameter>replacement</parameter></paramdef>
+ <paramdef>int <parameter>start</parameter></paramdef>
+ <paramdef>int
<parameter><optional>length</optional></parameter></paramdef>
+ </funcsynopsis>
+
+ <para>
+ <function>substr_replace</function> replaces the part of
+ <parameter>string</parameter> delimited by the
+ <parameter>start</parameter> and (optionally)
+ <parameter>length</parameter> parameters with the string given in
+ <parameter>replacement</parameter>. The result is returned.
+ </para>
+
+ <para>
+ If <parameter>start</parameter> is positive, the replacing will
+ begin at the <parameter>start</parameter>'th offset into
+ <parameter>string</parameter>.
+ </para>
+
+ <para>
+ If <parameter>start</parameter> is negative, the replacing will
+ begin at the <parameter>start</parameter>'th character from
+ the end of <parameter>string</parameter>.
+ </para>
+
+ <para>
+ If <parameter>length</parameter> is given and is positive, it
+ represents the length of the portion of
+ <parameter>string</parameter> which is to be replaced. If it is
+ negative, it represents the number of characters from the end of
+ <parameter>string</parameter> at which to stop replacing. If it
+ is not given, then it will default to strlen(
+ <parameter>string</parameter> ); i.e. end the replacing at the
+ end of <parameter>string</parameter>.
+ </para>
+
+ <para>
+ <example>
+ <title><function>substr_replace</function> example</title>
+ <programlisting>
+<?php
+$var = 'ABCDEFGH:/MNRPQR/';
+echo "Original: $var<hr>\n";
+
+/* These two examples replace all of $var with 'bob'. */
+echo substr_replace( $var, 'bob', 0 ) . "<br>\n";
+echo substr_replace( $var, 'bob', 0, strlen( $var ) ) . "<br>\n";
+
+/* Insert 'bob' right at the beginning of $var. */
+echo substr_replace( $var, 'bob', 0, 0 ) . "<br>\n";
+
+/* These next two replace 'MNRPQR' in $var with 'bob'. */
+echo substr_replace( $var, 'bob', 10, -1 ) . "<br>\n";
+echo substr_replace( $var, 'bob', -7, -1 ) . "<br>\n";
+
+/* Delete 'MNRPQR' from $var. */
+echo substr_replace( $var, '', 10, -1 ) . "<br>\n";
+?>
+ </programlisting>
+ </example>
+ </para>
+
+ <para>
+ See also <function>str_replace</function> and
+ <function>substr</function>.
+ </para>
+
+ </refsect1>
+ </refentry>
+
+
<refentry id="function.trim">
<refnamediv>
<refname>trim</refname>