count_sentences

计算变量内容有多少个句子。 每个句子必须以点号、问号或者感叹号结尾。(.?!)

Example 5.6. count_sentences


<?php

$smarty->assign('articleTitle',
                 'Two Soviet Ships Collide - One Dies.
                 Enraged Cow Injures Farmer with Axe.'
                 );

?>

   

模板是:


{$articleTitle}
{$articleTitle|count_sentences}

   

输出:


Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
2

   

参见 count_characters, count_paragraphscount_words.