Sophie

Sophie

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

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
>wordwrap</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="vsprintf"
HREF="function.vsprintf.html"><LINK
REL="NEXT"
TITLE="Shockwave Flash Functions"
HREF="ref.swf.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.vsprintf.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="ref.swf.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.wordwrap"
></A
>wordwrap</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN228915"
></A
><P
>    (PHP 4 &#62;= 4.0.2, PHP 5)</P
>wordwrap&nbsp;--&nbsp;
     Wraps a string to a given number of characters using a string
     break character
    </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN228918"
></A
><H2
>Description</H2
>string <B
CLASS="methodname"
>wordwrap</B
> ( string str [, int width [, string break [, bool cut]]] )<BR
></BR
><P
>&#13;     Returns a string with <CODE
CLASS="parameter"
>str</CODE
> wrapped
     at the column number specified by the optional
     <CODE
CLASS="parameter"
>width</CODE
> parameter.  The line is broken
     using the (optional) <CODE
CLASS="parameter"
>break</CODE
> parameter.
    </P
><P
>&#13;     <B
CLASS="function"
>wordwrap()</B
> will automatically wrap at column
     75 and break using '<TT
CLASS="literal"
>\n</TT
>' (newline) if 
     <CODE
CLASS="parameter"
>width</CODE
> or <CODE
CLASS="parameter"
>break</CODE
> 
     are not given.
    </P
><P
>&#13;     If the <CODE
CLASS="parameter"
>cut</CODE
> is set to <TT
CLASS="constant"
><B
>TRUE</B
></TT
>, the string is
     always wrapped at the specified width. So if you have a word
     that is larger than the given width, it is broken apart.
     (See second example).
     <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>注意: </B
>
       The optional <CODE
CLASS="parameter"
>cut</CODE
> parameter was added in PHP
       4.0.3
      </P
></BLOCKQUOTE
></DIV
>
    </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN228950"
></A
><P
><B
>例 1. <B
CLASS="function"
>wordwrap()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$text </font><font color="#007700">= </font><font color="#DD0000">"The quick brown fox jumped over the lazy dog."</font><font color="#007700">;<br /></font><font color="#0000BB">$newtext </font><font color="#007700">= </font><font color="#0000BB">wordwrap</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">, </font><font color="#0000BB">20</font><font color="#007700">, </font><font color="#DD0000">"&lt;br /&gt;\n"</font><font color="#007700">);<br /><br />echo </font><font color="#0000BB">$newtext</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;     This example would display:
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>The quick brown fox&#60;br /&#62;
jumped over the lazy&#60;br /&#62;
dog.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN228956"
></A
><P
><B
>例 2. <B
CLASS="function"
>wordwrap()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$text </font><font color="#007700">= </font><font color="#DD0000">"A very long woooooooooooord."</font><font color="#007700">;<br /></font><font color="#0000BB">$newtext </font><font color="#007700">= </font><font color="#0000BB">wordwrap</font><font color="#007700">(</font><font color="#0000BB">$text</font><font color="#007700">, </font><font color="#0000BB">8</font><font color="#007700">, </font><font color="#DD0000">"\n"</font><font color="#007700">, </font><font color="#0000BB">true</font><font color="#007700">);<br /><br />echo </font><font color="#DD0000">"$newtext</font><font color="#007700">\n</font><font color="#DD0000">"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>&#13;     This example would display:
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>A very
long
wooooooo
ooooord.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>&#13;     See also <A
HREF="function.nl2br.html"
><B
CLASS="function"
>nl2br()</B
></A
> and
     <A
HREF="function.chunk-split.html"
><B
CLASS="function"
>chunk_split()</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.vsprintf.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="ref.swf.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>vsprintf</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.strings.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Shockwave Flash Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>