Wordwrap in Smarty

Wordwrap in Smarty

Wordwrap wraps string to a column width, default is 80. We can specify the length to wrap a text to that length. We can also cut off th string at exact character length by passing the optional third parameter of true.

<?php

$smarty->assign(’input’,
“This is test text which will use wordwrap.”
);

?>

where template is

{$input}

{$input|wordwrap:30}

{$input|wordwrap:20}

{$input|wordwrap:30:”<br />\n”}

Output

This is test text which will

use wordwrap.

This is test text

which will use wordwrap.

This is test text which will<br />

use wordwrap.

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.