<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >ltrim</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="localeconv" HREF="function.localeconv.html"><LINK REL="NEXT" TITLE="md5_file" HREF="function.md5-file.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.localeconv.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.md5-file.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ltrim" ></A >ltrim</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN219739" ></A ><P > (PHP 3, PHP 4, PHP 5)</P >ltrim -- Retira whitespace do início da string </DIV ><DIV CLASS="refsect1" ><A NAME="AEN219742" ></A ><H2 >Descrição</H2 >string <B CLASS="methodname" >ltrim</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 uma string com whitespace retirados do início de <CODE CLASS="parameter" >str</CODE >. Sem o segundo parâmetro, <B CLASS="function" >ltrim()</B > retirará estes caracteres: <P ></P ><UL ><LI ><P > " " (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >32</TT > (<TT CLASS="literal" >0x20</TT >)), um espaço normal. </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 linha nova (line feed). </P ></LI ><LI ><P > "\r" (<ACRONYM CLASS="acronym" >ASCII</ACRONYM > <TT CLASS="literal" >13</TT > (<TT CLASS="literal" >0x0D</TT >)), um retono de carro. </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ê pode também especificar os caracteres que você quer retirar, por meio do parâmetro <CODE CLASS="parameter" >charlist</CODE >. Simplesmente lista todos os caracteres que você quer que sejam retirados. Com <TT CLASS="literal" >..</TT > você pode especificar um ordem de caracteres. </P ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN219793" ></A ><P ><B >Exemplo 1. Exemplo do uso de <B CLASS="function" >ltrim()</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">ltrim</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">);<br /></font><font color="#FF8000">// $trimmed = "These are a few words :) ... "<br /></font><font color="#0000BB">$trimmed </font><font color="#007700">= </font><font color="#0000BB">ltrim</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 = "These are a few words :) ... "<br /></font><font color="#0000BB">$clean </font><font color="#007700">= </font><font color="#0000BB">ltrim</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">// trim the ASCII control characters at the beginning of $binary <br />// (from 0 to 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.rtrim.html" ><B CLASS="function" >rtrim()</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.localeconv.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.md5-file.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >localeconv</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" >md5_file</TD ></TR ></TABLE ></DIV ></BODY ></HTML >