w3-tools.com - Free Webmaster Tools and Resources
 
w3-tools.com - Free Webmaster Tools and Resources
 Free Webmaster Tools and Resources

 



Smarty Manual

This manual is provided as a courtesy. It is not an official source. Please check smarty.php.net for updated information.

Smarty Manual

Smarty Manual

wordwrap

wordwrap wraps a string to a column width, default is 80. As an optional second parameter, you can specify a string of text to wrap the text to the next line (default is carriage return \n). By default, {wordwrap} will attempt to wrap at a word boundary. If you want to cut off at the exact character length, pass the optional third parameter of true. This is equivalent to the PHP wordwrap() function.

Parameter PositionTypeRequiredDefaultDescription
1integerNo80This determines how many columns to wrap to.
2stringNo\nThis is the string used to wrap words with.
3booleanNofalseThis determines whether or not to wrap at a word boundary (false), or at the exact character (true).

Example 5-22. wordwrap

<?php
    
$smarty
->assign('articleTitle',
                
"Blind woman gets new kidney from dad she hasn't seen in years."
               
);

?>

where template is

{$articleTitle}

{$articleTitle|wordwrap:30}
    
{$articleTitle|wordwrap:20}
    
{$articleTitle|wordwrap:30:"<br />\n"}
    
{$articleTitle|wordwrap:30:"\n":true}

This will output:

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 kidney
from dad she hasn't seen in
years.

See also nl2br and {textformat}.

Newsletter

Join to our newsletter and receive news and updates about our site.
Your name: 
E-mail address: 
Action: 
 

Hosted by

Search

Google
Web w3-tools.com

Links

  What is my IP? Find your IP address!     Valid XHTML 1.0 Transitional  
Copyright © 2006. by w3-tools.com. All rights reserved