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:
其中 index.tpl 的內容為:
{$articleTitle}
{$articleTitle|count_words} |
This will output:
輸出結果為:
Dealers Will Hear Car Talk at Noon.
7 |
|