> Smarty模板引擎中文在线手册 > count_words [计算词数]

count_words[计算词数]

This is used to count the number of words in a variable.
计算变量里的词数 。

Example 5-7. count_words

index.PHP:

$smarty = new Smarty;
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
$smarty->display('index.tpl');

index.tpl:

{$articleTitle}
{$articleTitle|count_words}

OUTPUT:

Dealers Will Hear Car Talk at Noon.
7
上一篇:
下一篇: