Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Smarty plugin
Chris PeBenito 696b41
 * @package Smarty
Chris PeBenito 696b41
 * @subpackage plugins
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Smarty count_paragraphs modifier plugin
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * Type:     modifier
Chris PeBenito 696b41
 * Name:     count_paragraphs
Chris PeBenito 696b41
 * Purpose:  count the number of paragraphs in a text
Chris PeBenito 696b41
 * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
Chris PeBenito 696b41
 *          count_paragraphs (Smarty online manual)
Chris PeBenito 696b41
 * @param string
Chris PeBenito 696b41
 * @return integer
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
function smarty_modifier_count_paragraphs($string)
Chris PeBenito 696b41
{
Chris PeBenito 696b41
    // count \r or \n characters
Chris PeBenito 696b41
    return count(preg_split('/[\r\n]+/', $string));
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
/* vim: set expandtab: */
Chris PeBenito 696b41
Chris PeBenito 696b41
?>