<!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="Manual do 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.quotemeta.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.setlocale.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.rtrim" ></A >rtrim</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN220289" ></A ><P > (PHP 3, PHP 4, PHP 5)</P >rtrim -- Retira espaço em branco do final da string </DIV ><DIV CLASS="refsect1" ><A NAME="AEN220292" ></A ><H2 >Descrição</H2 >string <B CLASS="methodname" >rtrim</B > ( string str [, string charlist] )<BR ></BR ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > O Segundo parâmetro foi adicionado no PHP 4.1.0 </P ></BLOCKQUOTE ></DIV ><P > Esta função retorna a string como os espaços em branco retirados do final de <CODE CLASS="parameter" >str</CODE >. Sem o segundo parâmetro, <B CLASS="function" >rtrim()</B > irá retirar os seguintes caracteres: <P ></P ><UL ><LI ><P > " " (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >32</TT > (<TT CLASS="literal" >0x20</TT >)), um espaço comum. </P ></LI ><LI ><P > "\t" (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >9</TT > (<TT CLASS="literal" >0x09</TT >)), uma tabulação. </P ></LI ><LI ><P > "\n" (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >10</TT > (<TT CLASS="literal" >0x0A</TT >)), uma nova linha. </P ></LI ><LI ><P > "\r" (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >13</TT > (<TT CLASS="literal" >0x0D</TT >)), um retorno de carro(ENTER). </P ></LI ><LI ><P > "\0" (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >0</TT > (<TT CLASS="literal" >0x00</TT >)), o byte <TT CLASS="literal" >NULL</TT >. </P ></LI ><LI ><P > "\x0B" (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >11</TT > (<TT CLASS="literal" >0x0B</TT >)), uma tabulação vertical. </P ></LI ></UL > </P ><P > Você também pode especificar os caracteres que você deseja retirar, pelo parâmetro <CODE CLASS="parameter" >charlist</CODE >. Simplesmente liste todos os caracteres que você quer ver retirados. Com <TT CLASS="literal" >..</TT > você pode especificar um intervalo de caracteres. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN220343" ></A ><P ><B >Exemplo 1. Exemplo de uso da função <B CLASS="function" >rtrim()</B ></B ></P ><P > <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br />$text </font><font color="#007700">= </font><font color="#DD0000">"\t\tThese are a few words :) ... "</font><font color="#007700">;<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="#FF8000">// $trimmed = "\t\tThese are a few words :) ..."<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="#FF8000">// $trimmed = "\t\tThese are a few words :)"<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">"\0x00..\0x1F"</font><font color="#007700">);<br /></font><font color="#FF8000">// retira os caracteres de controle ASCII ao final de $binary<br />// (de 0 até 31 inclusive)<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE > </P ></DIV ></TD ></TR ></TABLE ><P > Veja também <A HREF="function.trim.html" ><B CLASS="function" >trim()</B ></A > e <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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.setlocale.html" ACCESSKEY="N" >Próxima</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" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >setlocale</TD ></TR ></TABLE ></DIV ></BODY ></HTML >