Counting words and charaters using Smarty

Counting words and charaters using Smarty

we can count characters using smarty as follows.

<?php

$smarty->assign(’articleTitle’, ‘This is test string.’);

?>

Where template is:

{$articleTitle} // Display the text

{$articleTitle|count_characters} //Count characters without space

{$articleTitle|count_characters:true} //Count characters with space

{$articleTitle|count_words} //Count words

Output:

This is test string.

16

20

4

Leave a Reply

You must be logged in to post a comment.


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.