PHP Classes

File: htdocs/xoops_lib/vendor/smarty/smarty/docs/designers/language-modifiers/language-modifier-count-words.md

Recommend this page to a friend!
  Packages of Michael Beck   Xoops 2.5   htdocs/xoops_lib/vendor/smarty/smarty/docs/designers/language-modifiers/language-modifier-count-words.md   Download  
File: htdocs/xoops_lib/vendor/smarty/smarty/docs/designers/language-modifiers/language-modifier-count-words.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: Xoops 2.5
Modular content management publication system
Author: By
Last change:
Date: 2 months ago
Size: 587 bytes
 

Contents

Class file image Download

count_words

This is used to count the number of words in a variable.

Basic usage

{$myVar|count_words}

Examples

<?php

    $smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');

Where template is:

    {$articleTitle}
    {$articleTitle|count_words}

This will output:

    Dealers Will Hear Car Talk at Noon.
    7

See also count_characters, count_paragraphs and count_sentences.