Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 2518

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>str_replace</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="String functions"
HREF="ref.strings.html"><LINK
REL="PREVIOUS"
TITLE="str_repeat"
HREF="function.str-repeat.html"><LINK
REL="NEXT"
TITLE="str_rot13"
HREF="function.str-rot13.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.str-repeat.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.str-rot13.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.str-replace"
></A
>str_replace</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN90857"
></A
><P
>    (PHP 3&#62;= 3.0.6, PHP 4 )</P
>str_replace&nbsp;--&nbsp;
     Replace all occurrences of the search string with the replacement string
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN90860"
></A
><H2
>Description</H2
>mixed <B
CLASS="methodname"
>str_replace</B
> ( mixed search, mixed replace, mixed subject)<BR
></BR
><P
>&#13;     This function returns a string or an array with all occurences of
     <TT
CLASS="parameter"
><I
>search</I
></TT
> in <TT
CLASS="parameter"
><I
>subject</I
></TT
>
     replaced with the given <TT
CLASS="parameter"
><I
>replace</I
></TT
> value.  If
     you don't need fancy replacing rules, you should always use this
     function instead of <A
HREF="function.ereg-replace.html"
><B
CLASS="function"
>ereg_replace()</B
></A
> or
     <A
HREF="function.preg-replace.html"
><B
CLASS="function"
>preg_replace()</B
></A
>.
    </P
><P
>&#13;     In PHP 4.0.5 and later, every parameter to
     <B
CLASS="function"
>str_replace()</B
> can be an array.
    </P
><P
>&#13;     If <TT
CLASS="parameter"
><I
>subject</I
></TT
> is an array, then the search
     and replace is performed with every entry of
     <TT
CLASS="parameter"
><I
>subject</I
></TT
>, and the return value is an array
     as well.
    </P
><P
>&#13;     If <TT
CLASS="parameter"
><I
>search</I
></TT
> and
     <TT
CLASS="parameter"
><I
>replace</I
></TT
> are arrays, then
     <B
CLASS="function"
>str_replace()</B
> takes a value from each array
     and uses them to do search and replace on
     <TT
CLASS="parameter"
><I
>subject</I
></TT
>. If
     <TT
CLASS="parameter"
><I
>replace</I
></TT
> has fewer values than
     <TT
CLASS="parameter"
><I
>search</I
></TT
>, then an empty string is used for
     the rest of replacement values. If <TT
CLASS="parameter"
><I
>search</I
></TT
>
     is an array and <TT
CLASS="parameter"
><I
>replace</I
></TT
> is a string; then
     this replacement string is used for every value of
     <TT
CLASS="parameter"
><I
>search</I
></TT
>.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN90896"
></A
><P
><B
>Example 1. <B
CLASS="function"
>str_replace()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>$bodytag = str_replace("%body%", "black", "&#60;body text=%body%&#62;");</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     This function is binary safe.
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      <B
CLASS="function"
>str_replace()</B
> was added in PHP 3.0.6, but was
      buggy up until PHP 3.0.8.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also <A
HREF="function.ereg-replace.html"
><B
CLASS="function"
>ereg_replace()</B
></A
>,
     <A
HREF="function.preg-replace.html"
><B
CLASS="function"
>preg_replace()</B
></A
>, and <A
HREF="function.strtr.html"
><B
CLASS="function"
>strtr()</B
></A
>.
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.str-repeat.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.str-rot13.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>str_repeat</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>str_rot13</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>