⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.wordwrap.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Wraps a string to a given number of characters</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.strings.html">String Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="refs.basic.vartype.html">Variable and Type Related Extensions</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.wordwrap" class="refentry"> <div class="refnamediv">  <h1 class="refname">wordwrap</h1>  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5)</p><p class="refpurpose"><span class="refname">wordwrap</span> &mdash; <span class="dc-title">Wraps a string to a given number of characters</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">string</span> <span class="methodname"><b><b>wordwrap</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$str</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$width</tt></span>   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$break</tt></span>   [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$cut</tt></span>  ]]] )</div>  <p class="para rdfs-comment">   Wraps a string to a given number of characters using a string break   character.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">str</tt></i></span>     <dd>      <p class="para">       The input string.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">width</tt></i></span>     <dd>      <p class="para">       The column width. Defaults to 75.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">break</tt></i></span>     <dd>      <p class="para">       The line is broken using the optional       <i><tt class="parameter">break</tt></i> parameter. Defaults to        &#039;<i>\n</i>&#039;.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">cut</tt></i></span>     <dd>      <p class="para">       If the <i><tt class="parameter">cut</tt></i> is set to <b><tt>TRUE</tt></b>, 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).      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns the given string wrapped at the specified column.  </p> </div> <div class="refsect1 changelog">  <h3 class="title">ChangeLog</h3>  <p class="para">   <table class="informaltable">    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Version</th>       <th colspan="1">Description</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">4.0.3</td>       <td colspan="1" rowspan="1" align="left">        The optional <i><tt class="parameter">cut</tt></i> parameter was added.       </td>      </tr>     </tbody>    </colgroup>   </table>  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 <b>wordwrap()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$text&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"The&nbsp;quick&nbsp;brown&nbsp;fox&nbsp;jumped&nbsp;over&nbsp;the&nbsp;lazy&nbsp;dog."</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$newtext&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">wordwrap</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$newtext</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>The above example will output:</p></div>    <div class="example-contents"><pre><div class="cdata"><pre>The quick brown fox&lt;br /&gt;jumped over the lazy&lt;br /&gt;dog.</pre></div>    </pre></div>   </div>   <div class="example">    <p><b>Example #2 <b>wordwrap()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$text&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"A&nbsp;very&nbsp;long&nbsp;woooooooooooord."</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$newtext&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">wordwrap</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"$newtext\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>The above example will output:</p></div>    <div class="example-contents"><pre><div class="cdata"><pre>A verylongwoooooooooooord.</pre></div>    </pre></div>   </div>  </p> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.nl2br.html" class="function" rel="rdfs-seeAlso">nl2br()</a></li>    <li class="member"><a href="function.chunk-split.html" class="function" rel="rdfs-seeAlso">chunk_split()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.strings.html">String Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="refs.basic.vartype.html">Variable and Type Related Extensions</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -