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

count_sentences[计算句数]

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

Example 5-6. count_sentences

index.PHP:

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

index.tpl:

{$articleTitle}
{$articleTitle|count_sentences}

OUTPUT:

Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
2
上一篇:
下一篇: