Smarty Manual
Prev | Chapter 5. Variable Modifiers | Next

# count_words

This is used to count the number of words in a variable.

Example 5-7. count_words
`<?php $smarty = new Smarty; $smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.'); $smarty->display('index.tpl'); ?>`
Where index.tpl is:
    {$articleTitle}
    {$articleTitle|count_words}
This will output:
    Dealers Will Hear Car Talk at Noon.
    7

Prev | Home | Next
count_sentences | Up | date_format