/kdewebdev-3.5.10/php/function.strtr.html
HTML | 320 lines | 320 code | 0 blank | 0 comment | 0 complexity | ed5f98f02a50f4a6f85cf0a2994f6d17 MD5 | raw file
Possible License(s): AGPL-1.0, CC-BY-SA-3.0, GPL-2.0
- <HTML
- ><HEAD
- ><TITLE
- >strtr</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="strtoupper"
- HREF="function.strtoupper.html"><LINK
- REL="NEXT"
- TITLE="substr_count"
- HREF="function.substr-count.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.strtoupper.html"
- ACCESSKEY="P"
- >Prev</A
- ></TD
- ><TD
- WIDTH="80%"
- ALIGN="center"
- VALIGN="bottom"
- ></TD
- ><TD
- WIDTH="10%"
- ALIGN="right"
- VALIGN="bottom"
- ><A
- HREF="function.substr-count.html"
- ACCESSKEY="N"
- >Next</A
- ></TD
- ></TR
- ></TABLE
- ><HR
- ALIGN="LEFT"
- WIDTH="100%"></DIV
- ><H1
- ><A
- NAME="function.strtr"
- ></A
- >strtr</H1
- ><DIV
- CLASS="refnamediv"
- ><A
- NAME="AEN91647"
- ></A
- ><P
- > (PHP 3, PHP 4 )</P
- >strtr -- Translate certain characters</DIV
- ><DIV
- CLASS="refsect1"
- ><A
- NAME="AEN91650"
- ></A
- ><H2
- >Description</H2
- >string <B
- CLASS="methodname"
- >strtr</B
- > ( string str, string from, string to)<BR
- ></BR
- >string <B
- CLASS="methodname"
- >strtr</B
- > ( string str, array replace_pairs)<BR
- ></BR
- ><P
- > This function returns a copy of <TT
- CLASS="parameter"
- ><I
- >str</I
- ></TT
- >,
- translating all occurrences of each character in
- <TT
- CLASS="parameter"
- ><I
- >from</I
- ></TT
- > to the corresponding character in
- <TT
- CLASS="parameter"
- ><I
- >to</I
- ></TT
- > and returning the result.
- </P
- ><P
- > If <TT
- CLASS="parameter"
- ><I
- >from</I
- ></TT
- > and <TT
- CLASS="parameter"
- ><I
- >to</I
- ></TT
- > are
- different lengths, the extra characters in the longer of the two
- are ignored.
- <TABLE
- WIDTH="100%"
- BORDER="0"
- CELLPADDING="0"
- CELLSPACING="0"
- CLASS="EXAMPLE"
- ><TR
- ><TD
- ><DIV
- CLASS="example"
- ><A
- NAME="AEN91680"
- ></A
- ><P
- ><B
- >Example 1. <B
- CLASS="function"
- >strtr()</B
- > example</B
- ></P
- ><TABLE
- BORDER="0"
- BGCOLOR="#E0E0E0"
- CELLPADDING="5"
- ><TR
- ><TD
- ><PRE
- CLASS="php"
- >$addr = strtr($addr, "???", "aao");</PRE
- ></TD
- ></TR
- ></TABLE
- ></DIV
- ></TD
- ></TR
- ></TABLE
- >
- </P
- ><P
- > <B
- CLASS="function"
- >strtr()</B
- > can be called with only two
- arguments. If called with two arguments it behaves in a new way:
- <TT
- CLASS="parameter"
- ><I
- >from</I
- ></TT
- > then has to be an array that contains
- string -> string pairs that will be replaced in the source
- string. <B
- CLASS="function"
- >strtr()</B
- > will always look for the
- longest possible match first and will *NOT* try to replace stuff
- that it has already worked on.
- </P
- ><P
- > Examples:
- <DIV
- CLASS="informalexample"
- ><A
- NAME="AEN91689"
- ></A
- ><P
- ></P
- ><TABLE
- BORDER="0"
- BGCOLOR="#E0E0E0"
- CELLPADDING="5"
- ><TR
- ><TD
- ><PRE
- CLASS="php"
- >$trans = array("hello" => "hi", "hi" => "hello");
- echo strtr("hi all, I said hello", $trans) . "\n";</PRE
- ></TD
- ></TR
- ></TABLE
- ><P
- ></P
- ></DIV
- >
- This will show: "hello all, I said hi",
- </P
- ><DIV
- CLASS="note"
- ><BLOCKQUOTE
- CLASS="note"
- ><P
- ><B
- >Note: </B
- >
- This optional <TT
- CLASS="parameter"
- ><I
- >to</I
- ></TT
- > and
- <TT
- CLASS="parameter"
- ><I
- >from</I
- ></TT
- > parameters were added in PHP 4.0.0
- </P
- ></BLOCKQUOTE
- ></DIV
- ><P
- > See also <A
- HREF="function.ereg-replace.html"
- ><B
- CLASS="function"
- >ereg_replace()</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.strtoupper.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.substr-count.html"
- ACCESSKEY="N"
- >Next</A
- ></TD
- ></TR
- ><TR
- ><TD
- WIDTH="33%"
- ALIGN="left"
- VALIGN="top"
- >strtoupper</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"
- >substr_count</TD
- ></TR
- ></TABLE
- ></DIV
- ></BODY
- ></HTML
- >