Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 9408

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>rtrim</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="String 字符串处理函数"
HREF="ref.strings.html"><LINK
REL="PREVIOUS"
TITLE="quotemeta"
HREF="function.quotemeta.html"><LINK
REL="NEXT"
TITLE="setlocale"
HREF="function.setlocale.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.quotemeta.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.setlocale.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.rtrim"
></A
>rtrim</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN226531"
></A
><P
>    (PHP 3, PHP 4, PHP 5)</P
>rtrim&nbsp;--&nbsp;
     Strip whitespace (or other characters) from the end of a string
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN226534"
></A
><H2
>Description</H2
>string <B
CLASS="methodname"
>rtrim</B
> ( string str [, string charlist] )<BR
></BR
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
      The second parameter was added in PHP 4.1.0
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     This function returns a string with whitespace stripped from the
     end of <CODE
CLASS="parameter"
>str</CODE
>.
     Without the second parameter,
     <B
CLASS="function"
>rtrim()</B
> will strip these characters:
     
     <P
></P
><UL
><LI
><P
>&#13;        " " (<ACRONYM
CLASS="acronym"
>ASCII</ACRONYM
> <TT
CLASS="literal"
>32</TT
> 
        (<TT
CLASS="literal"
>0x20</TT
>)), an ordinary space.
       </P
></LI
><LI
><P
>&#13;        "\t" (<ACRONYM
CLASS="acronym"
>ASCII</ACRONYM
> <TT
CLASS="literal"
>9</TT
> 
        (<TT
CLASS="literal"
>0x09</TT
>)), a tab.
       </P
></LI
><LI
><P
>&#13;        "\n" (<ACRONYM
CLASS="acronym"
>ASCII</ACRONYM
> <TT
CLASS="literal"
>10</TT
> 
        (<TT
CLASS="literal"
>0x0A</TT
>)), a new line (line feed).
       </P
></LI
><LI
><P
>&#13;        "\r" (<ACRONYM
CLASS="acronym"
>ASCII</ACRONYM
> <TT
CLASS="literal"
>13</TT
> 
        (<TT
CLASS="literal"
>0x0D</TT
>)), a carriage return.
       </P
></LI
><LI
><P
>&#13;        "\0" (<ACRONYM
CLASS="acronym"
>ASCII</ACRONYM
> <TT
CLASS="literal"
>0</TT
> 
        (<TT
CLASS="literal"
>0x00</TT
>)), the <TT
CLASS="literal"
>NUL</TT
>-byte.
       </P
></LI
><LI
><P
> 
        "\x0B" (<ACRONYM
CLASS="acronym"
>ASCII</ACRONYM
> <TT
CLASS="literal"
>11</TT
> 
        (<TT
CLASS="literal"
>0x0B</TT
>)), a vertical tab.
       </P
></LI
></UL
>
    </P
><P
>&#13;     You can also specify the characters you want to strip, by means
     of the <CODE
CLASS="parameter"
>charlist</CODE
> parameter.
     Simply list all characters that you want to be stripped. With
     <TT
CLASS="literal"
>..</TT
> you can specify a range of characters.
    </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN226585"
></A
><P
><B
>例 1. Usage example of <B
CLASS="function"
>rtrim()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /><br />$text </font><font color="#007700">= </font><font color="#DD0000">"\t\tThese are a few words :) ...&nbsp;&nbsp;"</font><font color="#007700">;<br /></font><font color="#0000BB">$binary </font><font color="#007700">= </font><font color="#DD0000">"\x09Example string\x0A"</font><font color="#007700">;<br /></font><font color="#0000BB">$hello&nbsp;&nbsp;</font><font color="#007700">= </font><font color="#DD0000">"Hello World"</font><font color="#007700">;<br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">, </font><font color="#0000BB">$binary</font><font color="#007700">, </font><font color="#0000BB">$hello</font><font color="#007700">);<br /><br />print </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$trimmed </font><font color="#007700">= </font><font color="#0000BB">rtrim</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">);<br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$trimmed</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$trimmed </font><font color="#007700">= </font><font color="#0000BB">rtrim</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">, </font><font color="#DD0000">" \t."</font><font color="#007700">);<br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$trimmed</font><font color="#007700">);<br /><br /></font><font color="#0000BB">$trimmed </font><font color="#007700">= </font><font color="#0000BB">rtrim</font><font color="#007700">(</font><font color="#0000BB">$hello</font><font color="#007700">, </font><font color="#DD0000">"Hdle"</font><font color="#007700">);<br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$trimmed</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// trim the ASCII control characters at the end of $binary<br />// (from 0 to 31 inclusive)<br /></font><font color="#0000BB">$clean </font><font color="#007700">= </font><font color="#0000BB">rtrim</font><font color="#007700">(</font><font color="#0000BB">$binary</font><font color="#007700">, </font><font color="#DD0000">"\x00..\x1F"</font><font color="#007700">);<br /></font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$clean</font><font color="#007700">);<br /><br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>string(32) "        These are a few words :) ...  "
string(16) "    Example string
"
string(11) "Hello World"

string(30) "        These are a few words :) ..."
string(26) "        These are a few words :)"
string(9) "Hello Wor"
string(15) "    Example string"</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;     See also <A
HREF="function.trim.html"
><B
CLASS="function"
>trim()</B
></A
> and <A
HREF="function.ltrim.html"
><B
CLASS="function"
>ltrim()</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.quotemeta.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.setlocale.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>quotemeta</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>setlocale</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>