<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>wordwrap</title> <meta name="generator" content="DocBook XSL Stylesheets V1.75.1"> <link rel="home" href="index.html" title="Smarty Manual"> <link rel="up" href="language.modifiers.html" title="Chapter 5. Variable Modifiers"> <link rel="prev" href="language.modifier.upper.html" title="upper"> <link rel="next" href="language.combining.modifiers.html" title="Chapter 6. Combining Modifiers"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr><th colspan="3" align="center">wordwrap</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="language.modifier.upper.html">Prev</a> </td> <th width="60%" align="center">Chapter 5. Variable Modifiers</th> <td width="20%" align="right"> <a accesskey="n" href="language.combining.modifiers.html">Next</a> </td> </tr> </table> <hr> </div> <div class="sect1" title="wordwrap"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> <a name="language.modifier.wordwrap"></a>wordwrap</h2></div></div></div> <p> Wraps a string to a column width, the default is 80. As an optional second parameter, you can specify a string of text to wrap the text to the next line, the default is a carriage return <code class="literal">"\n"</code>. By default, <code class="varname">wordwrap</code> will attempt to wrap at a word boundary. If you want to cut off at the exact character length, pass the optional third parameter as <code class="constant">TRUE</code>. This is equivalent to the PHP <a class="ulink" href="http://php.net/wordwrap" target="_top"><code class="varname">wordwrap()</code></a> function. </p> <div class="informaltable"><table border="1"> <colgroup> <col align="center"> <col align="center"> <col align="center"> <col align="center"> <col> </colgroup> <thead><tr> <th align="center">Parameter Position</th> <th align="center">Type</th> <th align="center">Required</th> <th align="center">Default</th> <th>Description</th> </tr></thead> <tbody> <tr> <td align="center">1</td> <td align="center">integer</td> <td align="center">No</td> <td align="center">80</td> <td>This determines how many columns to wrap to.</td> </tr> <tr> <td align="center">2</td> <td align="center">string</td> <td align="center">No</td> <td align="center">\n</td> <td>This is the string used to wrap words with.</td> </tr> <tr> <td align="center">3</td> <td align="center">boolean</td> <td align="center">No</td> <td align="center"><code class="constant">FALSE</code></td> <td>This determines whether or not to wrap at a word boundary (<code class="constant">FALSE</code>), or at the exact character (<code class="constant">TRUE</code>).</td> </tr> </tbody> </table></div> <div class="example"> <a name="id3041251"></a><p class="title"><b>Example 5.23. wordwrap</b></p> <div class="example-contents"> <pre class="programlisting"> <?php $smarty->assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years." ); ?> </pre> <p> Where template is </p> <pre class="programlisting"> {$articleTitle} {$articleTitle|wordwrap:30} {$articleTitle|wordwrap:20} {$articleTitle|wordwrap:30:"<br />\n"} {$articleTitle|wordwrap:26:"\n":true} </pre> <p> Will output: </p> <pre class="screen"> Blind woman gets new kidney from dad she hasn't seen in years. Blind woman gets new kidney from dad she hasn't seen in years. Blind woman gets new kidney from dad she hasn't seen in years. Blind woman gets new kidney<br /> from dad she hasn't seen in<br /> years. Blind woman gets new kidn ey from dad she hasn't se en in years. </pre> </div> </div> <br class="example-break"><p> See also <a class="link" href="language.modifier.nl2br.html" title="nl2br"><code class="varname">nl2br</code></a> and <a class="link" href="language.function.textformat.html" title="{textformat}"><code class="varname">{textformat}</code></a>. </p> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="language.modifier.upper.html">Prev</a> </td> <td width="20%" align="center"><a accesskey="u" href="language.modifiers.html">Up</a></td> <td width="40%" align="right"> <a accesskey="n" href="language.combining.modifiers.html">Next</a> </td> </tr> <tr> <td width="40%" align="left" valign="top">upper </td> <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td> <td width="40%" align="right" valign="top"> Chapter 6. Combining Modifiers</td> </tr> </table> </div> </body> </html>