<HTML ><HEAD ><TITLE >rtrim</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="quotemeta" HREF="function.quotemeta.html"><LINK REL="NEXT" TITLE="setlocale" HREF="function.setlocale.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.quotemeta.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.setlocale.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.rtrim" ></A >rtrim</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN90443" ></A ><P > (PHP 3, PHP 4 )</P >rtrim -- Strip whitespace from the end of a string </DIV ><DIV CLASS="refsect1" ><A NAME="AEN90446" ></A ><H2 >Description</H2 >string <B CLASS="methodname" >rtrim</B > ( string str [, string charlist])<BR ></BR ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > The second parameter was added in PHP 4.1.0 </P ></BLOCKQUOTE ></DIV ><P > This function returns a string with whitespace stripped from the end of <TT CLASS="parameter" ><I >str</I ></TT >. Without the second parameter, <B CLASS="function" >rtrim()</B > will strip these characters: <P ></P ><UL ><LI ><P > " " (<SPAN CLASS="acronym" >ASCII</SPAN > <TT CLASS="literal" >32</TT > (<TT CLASS="literal" >0x20</TT >)), an ordinary space. </P ></LI ><LI ><P > "\t" (<SPAN CLASS="acronym" >ASCII</SPAN > <TT CLASS="literal" >9</TT > (<TT CLASS="literal" >0x09</TT >)), a tab. </P ></LI ><LI ><P > "\n" (<SPAN CLASS="acronym" >ASCII</SPAN > <TT CLASS="literal" >10</TT > (<TT CLASS="literal" >0x0A</TT >)), a new line (line feed). </P ></LI ><LI ><P > "\r" (<SPAN CLASS="acronym" >ASCII</SPAN > <TT CLASS="literal" >13</TT > (<TT CLASS="literal" >0x0D</TT >)), a carriage return. </P ></LI ><LI ><P > "\0" (<SPAN CLASS="acronym" >ASCII</SPAN > <TT CLASS="literal" >0</TT > (<TT CLASS="literal" >0x00</TT >)), the <TT CLASS="literal" >NUL</TT >-byte. </P ></LI ><LI ><P > "\x0B" (<SPAN CLASS="acronym" >ASCII</SPAN > <TT CLASS="literal" >11</TT > (<TT CLASS="literal" >0x0B</TT >)), a vertical tab. </P ></LI ></UL > </P ><P > You can also specify the characters you want to strip, by means of the <TT CLASS="parameter" ><I >charlist</I ></TT > 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="AEN90497" ></A ><P ><B >Example 1. Usage example of <B CLASS="function" >rtrim()</B ></B ></P ><P > <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $text = "\t\tThese are a few words :) ... "; $trimmed = rtrim($text); // $trimmed = "\t\tThese are a few words :) ..." $trimmed = rtrim($text," \t."); // $trimmed = "\t\tThese are a few words :)" $clean = rtrim($binary,"\0x00..\0x1F"); // trim the ASCII control characters at the end of $binary // (from 0 to 31 inclusive) ?></PRE ></TD ></TR ></TABLE > </P ></DIV ></TD ></TR ></TABLE ><P > 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" >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.setlocale.html" ACCESSKEY="N" >Next</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" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >setlocale</TD ></TR ></TABLE ></DIV ></BODY ></HTML >