转到内容

count_paragraphs

这用于计算变量中段落的数量。

基本用法

{$myVar|count_paragraphs}

示例

<?php

    $smarty->assign('articleTitle',
                     "War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.\n\n
                     Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation."
                    );

模板所在位置

    {$articleTitle}
    {$articleTitle|count_paragraphs}

将会输出

    War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.

    Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
    2

另请参阅count_characterscount_sentencescount_words